I understand that this is a really stupid idea, but could you theoretically accomplish this by inheriting by creating friend constructors of the parent class? The code is compiled, at least dubious, although it may be.
class A { public: A() { } private: int i; }; class D { public: D() { } private: int i; }; class B : public A { public: B() { } private: friend D::D(); }; class C : public D { public: C() { } private: friend A::A(); };
Chris frederick
source share