How to call child class method from parent variable in c++?
Answers
Answered by
0
#include <iostream>
struct SuperClass
{
virtual void show() { std::cout << "SuperClass\n"; }
virtual ~SuperClass() {}
};
struct Child
{
virtual void show() { std::cout << "Child\n"; }
};
int main()
{
SuperClass *obj = new Child;
obj->show();
}
Similar questions