recursive friend classes

后端 未结 4 1860
情深已故
情深已故 2021-01-17 22:03

Is there any way around this:

class B;

class C { 
 public:
  C() { }
 private:
  int i;
  friend B::B();
};

class B { 
 public:
  B() { }
 private:
  int i         


        
4条回答
  •  抹茶落季
    2021-01-17 22:32

    Since you're very selective about friendship (access to specific member functions given to specific classes), the Attorney-Client Idiom may be what you need. I'm not sure how well this will work with constructors, though.

提交回复
热议问题