## 21.5 (cont.) RTTI - the Dynamic Cast

- Check return type to test type:

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

prev |top |next