3 ms·
What? Every language I've used you can easily override a parent method with a method in the child class.
by timw4mail 7y ago
What? Every language I've used you can easily override a parent method with a method in the child class.
- deleted 7y ago[deleted]
- gpderetta 7y agoNot in C++ unless a method is explicitly marked as virtual. IIRC C# behaves in the same way. In Java, D, all methods are virtual by default. Most dynamic languages also behave in the same way (due to pervasive late binding).
- protomolecule 7y agoI haven't thought of Java. As the sibling comment says, it's the case for C++ and C#. In case of Java I agree with ernst_klim's critique, to me it's a poor language design choice. Dynamic languages are a mess anyway, but that's just my opinion :)
- pjmlp 7y agoJava went with Smalltalk/Objective-C/Modula-3 defaults, because it was heavily inspired by them in language sematics. However you can still terminate a virtual chain, or not offer it at all with the final modifier.