Computer Science, asked by Ashkingsinghani6912, 1 year ago

How to call child class method from parent variable in c++?

Answers

Answered by aravinthveer006
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