Displaying an Employee’s Type

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).


Image Portability Tip 12.1

The string returned by type_info member function name may vary by compiler.


..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.227.111.58