#include <iostream>
class base
{
public:
base()
{
std::cout << "base()";
}
virtual ~base()
{
std::cout << "~base()";
}
void f()
{
std::cout << "base f()";
}
};
class derived: public base
{
public:
derived()
{
std::cout << "derived()";
}
~derived()
{
std::cout << "~derived()";
}
void f()
{
std::cout << "derived f()";
}
};
int main()
{
base* ob = new derived;
dynamic_cast<derived*>(ob)->f();
return 0;
}
Login in to like
Login in to comment