#include <iostream>
class A
{
private:
virtual void VirtualMethod()
{
std::cout << "A::VirtualMethod()";
}
public:
void TestMethod()
{
VirtualMethod();
}
virtual ~A() {}
};
class B : public A
{
private:
void VirtualMethod()
{
std::cout << "B::VirtualMethod()";
}
public:
~B() {}
};
int main()
{
A* a = new B();
a->TestMethod();
delete a;
return 0;
}
Login in to like
Login in to comment