Since class friendship is not inherited in C++, what's the best way to "fake" it?
I was thinking about exposing the friend class's private interface through protected methods in the to-be-inherited base-class, but that results in having to write (and maintain) the same interface twice.
Are there any other ways?
The use of a key is a possible solution.
The idea is that you can unlock the operations only if you have a key... but an example is worth thousands on word so let's dive:
The matter of key being copy constructable is up to discussion. I don't see what you can gain by preventing it.
Another benefit is that you can have several keys, depending on which method you want to access, this way you grant 'partial' friendship, and your 'partial' friends can't mess around with your private parts, despite the famous claim!
EDIT:
This method is called Limited Friendship, and was discussed on comp.lang.c++.moderated.
The main advantage of this method in comparison to Private Interface, is the loose coupling, since only forward declarations are necessary.