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

Exercise 4.3
Friends and 'enemies' of a class with private and public bases


In this program from the accompanying slide introduce a friend function void frD(D &ad) of class D. (You can just delete the function f).

From frD access b, c, d in ad. Also from frD call the member functions Bop, Cop, and Dop on ad.

From an identical non-friend function (let us just call it an enemy) do exactly the same as in FrD.

Do you get the results you expect?

Can you arrange that frD can access/call all of b, c, d, Bop, Cop, and Dop?


Solution