#include <iostream>
class Base
{
public:
virtual void PrintName() { std::cout << "Base\n"; }
virtual ~Base() {}
};
class Derived : public Base
{
public:
virtual void PrintName() { std::cout << "Derived\n"; }
};
int main()
{
Base* base = new Base;
Base* derived = new Derived;
base->PrintName();
derived->PrintName();
delete base;
delete derived;
return 0;
}
Comments
Leave a comment