Exercises in this lecture  previous -- Keyboard shortcut: 'p'        Go to the slide, where this exercise belongs -- Keyboard shortcut: 'u'  

Exercise 5.2
Hiding inherited names

This is an exercise about an apparently weird happening in a C++ program with overloaded functions. It is good for you to wonder - and realize what happens. The solution is not not necessarily easy to find 'without cheating'...

The program shown together with this slide illustrates a simple situation when the derived class B inherits two virtual functions from a base class A. Everething is fine.

Redefine (override) vf in the derived class B, and keep the main function unchanged? Is everything still fine?

Discuss potential problems. Can you explain your experiences. Can you find a way to solve the problems you may have encountered?

If you have the book Effective C++, Third edition you are encouraged to read item 33.