## 21.3 Virtual and Nonvirtual Overriding (cont.)

- If an object invokes an operation, statically bound:

  > `Employee e("Lisa Lim", 36000);
  > cout << e.annual_income() << "\n"; // Statically bound`

- If a virtual method is invoked through a pointer or a reference, it is bound dynamically:

  > `Employee* e = new Manager("Sarah Smith", 67000, 2000);
  > cout << e->get_salary() << "\n";
  > // Static binding, because get_salary is not virtual
  > cout << e->annual_income() << "\n";
  > // Dynamic binding, because annual_income is virtual`

prev |top |next