home *** CD-ROM | disk | FTP | other *** search
- #include <iostream.h>
- #include <typeinfo.h>
-
- // Define our classes
- class Base {
- // Do nothing
- // Force polymorphism
- virtual void Nothing() { }
- };
-
- class Middle : public Base {
- // Do nothing
- };
-
- class Derived : public Middle {
- // Do nothing
- };
-
- // Show before relationship
- void ShowBefore(const type_info& info1,
- const type_info& info2)
- {
- cout << info1.name();
- cout << (info1.before(info2) ? " is " : " is not ");
- cout << "before " << info2.name() << "\n";
- }
-
- void main()
- {
- // Show the relationships
- ShowBefore(typeid(Base), typeid(Middle));
- ShowBefore(typeid(Base), typeid(Derived));
- ShowBefore(typeid(Middle), typeid(Base));
- ShowBefore(typeid(Middle), typeid(Derived));
- ShowBefore(typeid(Derived), typeid(Base));
- ShowBefore(typeid(Derived), typeid(Middle));
- }
-