home *** CD-ROM | disk | FTP | other *** search
- #include <iostream.h>
-
- class Base {
- // Do nothing (not a polymorphic class)
- };
-
- class Derived : public Base {
- // Do nothing (not a polymorphic class)
- };
-
- void main()
- {
- Derived MyDerived;
- Derived* pMyDerived = &MyDerived;
-
- // Successful upcast
- Base* pBaseTest = dynamic_cast<Base*>(pMyDerived);
- cout << "pMyDerived ";
- cout << (pBaseTest ? "is" : "is not");
- cout << " a Base*.\n";
- }
-