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

6th May 2020, 12:02 AM
Kiwwi#
Kiwwi# - avatar
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
15th May 2020, 5:39 PM
DeX97
+ 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/
16th May 2020, 10:09 AM
DeX97
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
15th May 2020, 9:54 PM
Kiwwi#
Kiwwi# - avatar