|
|
|
|
|
by throwawaylinux
1640 days ago
|
|
It frequently has structures containing objects of different types that have to identify themselves so they can be processed in different ways. This general pattern, and function pointers in C predates formal "OOP" of course, so I don't call it manually-written vtables. But yes it has this and it is a good technique. OOP languages which do this automatically for you is AFAIKS just a thin and often clunky layer of syntactic sugar on top of it. |
|
That sugar does help.
C allows adding another function pointer to that structure, but not set that pointer. C++ compiler forces programmers to implement all interface methods. Forget to override a method, the code which instantiates the class won’t compile complaining about not being able to instantiate an abstract class.
Code navigation is another thing. In visual studio, while the cursor is over an abstract method, F12 key looks up all implementations of the abstract class, and populates the “find symbol results” panel with a clickable list of the implementations of the method. With visual assist addon installed, Alt+G key does the same only presents the results in a popup menu instead of a separate panel.
Both things are borderline useless for small projects, but IMO they help a lot for medium to large ones, especially developed by multiple people.