I have a situation where I want to hide a base class and limit the classes that can inherit from it:
namespace _detail {
class Private abstract final {
struct Base abstract {
protected:
Base() {}
};
friend struct ::A;
friend struct ::B;
friend struct ::C;
};
}
struct A : _detail::Private::Base {}; //error
struct B : _detail::Private::Base {}; //error
struct C : _detail::Private::Base {}; //error
The compiler tells me that _detail::Private::Base
is inaccessible to A
, B
and C
even though they are friends with Private
. I've used this sort of pattern before without an issue, and can't really see what's different here compared to the other times I've used it. What am I not seeing?