## 21.3 Virtual and Nonvirtual Overriding (cont.)

- Passing an instance of a derived class might be confusing:

  >     void print(ostream& out, Employee& emp)
  >     {
  >        out << emp << "\n";
  >     }

  >     print(cout, *man);
  >        // Will print name as Employee not as Manager

- `emp`'s static type (`Employee`) is used to choose `operator<<`
- Try restructuring the flow of control (next slide):

prev |top |next