constructor A
constructor A
constructor B
1
1
destructor B
destructor A
destructor A
but I would like to see
constructor A
constructor A
constructor B
1
2
destructor B
destructor A
destructor A
Basically, I want the print method which is inherited in the B class to evoke m() method which is declared in B class and not the one from the A class. I guess I have to use virtual functions, but I don't know which methods should be made virtual.
That is precisely what I would like to avoid. The code I have posted is just a huge simplification of my real code. The print function is much, much longer in my real code and I have couple of classes that are derived from A. So even though, this is the simplest solution I would like to avoid it, because than I would have to duplicate the print() method in all my derived classes.