## 21.5.1 The `typeid` Operator (cont.)

- Another way to test an object's type
- Compare its `typeinfo` value to that of a known type:

  >     for (int i = 0; i < department.size(); i++)
  >     {
  >        if (typeid(*department[i]) == typeid(Manager))
  >           cout << "Employee " << department[i]->get_name()
  >              << " is a manager. \n";
  >        else
  >           cout << "Employee " << department[i]->get_name()
  >              << " is not a manager. \n";
  >     }

- Warning: Comparisons between types and pointers will always fail

prev |top |next