I am just testing with virtual keyword and inheritance concepts in c++. I have written a small program:
#include #include us
If you REALLY MUST do it like this, i.e. have a pointer to one class and initialise as a derived class, there's no choice but to always cast the pointer to the correct type when using it. In this case, ((cna_bsc*)_mo)->print(5);
((cna_bsc*)_mo)->print(5);