#include <iostream>
struct A
{
virtual void method() const { std::cout << "A" << std::endl; }
virtual ~A(){}
};
struct B : A
{
virtual void method() { std::cout << "B" << std::endl; }
};
int main() {
A * ptr = new B();
ptr->method();
delete ptr;
return 0;
}
Login in to like
Login in to comment