#include <iostream>
#include <exception>
using std::cout;
using std::endl;
class Base {
virtual void method() {
cout << "class Base" << endl;
}
};
class Derived : public Base {
virtual void method() {
cout << "class Derived" << endl;
}
};
int main()
{
try
{
Base *pb = new Derived;
Derived *pd;
pd = dynamic_cast<Derived*>(pb);
cout << pb << endl;
cout << pd << endl;
}
catch (std::exception &e) {
cout << "Exception: " << e.what();
}
return 0;
}
/*
run:
00736038
00736038
*/