HP aC++/HP C A.06.20 Programmer's Guide
};
void Base::f()
{
// Define function from Base.
}
void main ()
{
Base *p;
// code which does either
// p = new Base; or
// p = new Derived;
if (typeid(*p) == typeid(Base)) // Standard requires
// comparison as part
// of this class.
cout << “Base Object\n”;
cout << typeid(*p).name() << ‘\n’; // Standard requires
// access to the name
// of the type.
}
The standard requires the class type_info to be polymorphic. You cannot assign or
copy instances of the class (the copy constructor and assignment operators are private).
The interface must include:
int operator == (const type_info&) const
int operator !=( const type_info&) const
const char * name() const
int before (const type_info&) const
The operators allow comparison of object types. The name function allows access to
the character string representing the name of the object. The before function allows
types to be sorted. This allows them to be accessed through hash tables. The before
function is not a lexical ordering; it might not yield the same results. The name function
now returns the mangled name of a type as per the C++ ABI. This string can not be
demangled with __cxa_demangle.
Unsupported Functionality
Functionality defined in the ANSI/ISO C++ International Standard and not supported
in this release of HP aC++ is listed in Table 6-2. Library functionality is listed separately.
Unsupported Functionality 197