#include using namespace std; class BC { public: // Inheritance in C++ is not similar to Java. The method above will not be automatically overrride void show(void) { cout << " \n I am in base class.."; } // Unless we add the keyword virtual on it. Comment the line above and uncomment the line below to test. // virtual void show(void) { cout << " \n I am in base class.."; } }; class DC : public BC { public: void show(void) { cout << " \n I am derived class.."; } }; int main() { BC* ptr1; DC dobj; ptr1 = &dobj; ptr1->show(); }