Sorry for the Noob question .I have been learning C++ for a while and from the book “Visual C++” by Ivor Horton I see that when extending some class the methods overriding is done in the header of the derived class.I haven’t found any example where it can be done in .cpp files.So my question is if the .cpp files can only contains the “native” methods of the current class?Or there is a way also to override parent methods there.
Share
You can use .h and .cpp as you wish. You can have both declaration and definition in both .h and .cpp’s. Not that you should, but you can. cpp’s are compiled by the compiler, if you include your .h in a cpp, it will also be compiled. So to answer your question, yes, you can override in the cpp.
Example:
A.h
B.cpp
B will however only be visible in
B.cpp.Don’t do it thoguht!