Lines 55–62 display each employee’s object type and uses the delete
operator to deallocate the dynamic memory to which each vector
element points. Operator typeid (line 59) returns a reference to an object of class type_info that contains the information about the type of its operand, including the name of that type. When invoked, type_info
member function name (line 59) returns a pointer-based string containing the typeid
argument’s type name (e.g., "class BasePlusCommissionEmployee"
). To use typeid
, the program must include header <typeinfo> (line 8).
Portability Tip 12.1
The string returned by type_info member function name may vary by compiler.
3.142.196.223