0
Doubt about repeated functions in inheritance
If got a family of classes and the base is an abstract class, all the functions that must be repeated... *its that repetition necessary cause the language itself (compiler, syntax..) need it? Or is there a major reason? *that repetition its just for the compiler, or the generated compiled code got repetitions too? Thx
3 ответов
+ 1
You need to repeat the function declaration to indicate that you are giving a definition for that function. If you wouldn't state the function declaration, then the compiler doesn't know for which function you are giving the definition. Consider the example below:
https://code.sololearn.com/cAL515fNu150/?ref=app
+ 1
Kiwwi Okay, I misunderstood your question then. It indeed is related to a so-called virtual table! I would advise you to take a look at the (in my opinion very good) explanation on this site: https://www.learncpp.com/cpp-tutorial/125-the-virtual-table/
0
DeX97 thx for answer, I know that, but just want know what's happening in the background, think its related to virtual ptr table