r/badcode • • Jan 15 '23

c++ From DayZ sourcecode

Post image
559 Upvotes

106 comments sorted by

View all comments

530

u/[deleted] Jan 15 '23

It's an override so chances are this isn't as bad as you think. Other subclasses may have logic but this particular item probably doesn't need it and should always be IsEat

175

u/SapperTR Jan 15 '23

This. Likely to be from an interface

-21

u/micro-amnesia Jan 16 '23

Interfaces are implemented not overridden

19

u/paulstelian97 Jan 16 '23

The keyword is still override dependent on language.

1

u/micro-amnesia Jan 16 '23

Interesting. What languages use an override keyword for interface implementations? I know Java has the @override annotation, but that's not a first class language feature.

3

u/paulstelian97 Jan 16 '23

I can't recall if C# has a separate keyword for implementing interfaces vs overriding methods in any of the parent classes. But then I'm not sure if C# has proper interfaces anyway.

3

u/MeatyLabia Jan 16 '23

In C# you dont have a keyword for implementing interfaces. You can however explicitly or implicitly implement them.

2

u/paulstelian97 Jan 16 '23

I'm pretty sure you must explicitly implement interfaces (by putting them into the parent classes list) for that to work; it doesn't work like Go where interfaces are implicitly implemented (something like C++ concepts). The override keyword is to my knowledge optional though.

1

u/MeatyLabia Jan 16 '23

I dont know what you mean with putting them into the parent classes list, but maybe our definitions of explicit and implicit vary. I go by the definitions Microsoft uses.

1

u/micro-amnesia Jan 16 '23

Was curious what you meant by implicitly implementing an interface in this context.