HP aC++/HP C Programmer's Guide (B3901-90036; A.06.26; September 2011)

{
// Define function from Base.
}
int 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.
Unsupported Functionality
Functionality defined in the ANSI/ISO C++ International Standard and not supported in
this release of HP aC++ is listed in Table 11. Library functionality is listed separately.
Table 11 Unsupported Functionality
libc **Rogue Wave Standard C++
Library 1.2.1
Rogue Wave
Standard C++
Library 2.2.1
Functionality
Unsupported Functionality 191