http://en.wikibooks.org/wiki/More_C++_Idioms/Friendship_and_the_Attorney-Client

 

class Client 
{
private:
  void A(int a);
  void B(float b);
  void C(double c);
  friend class Attorney;
};
 
class Attorney {
private:
  static void callA(Client & c, int a) {
    c.A(a);
  } 
  static void callB(Client & c, float b) {
    c.B(b);
  }
  friend class Bar;
};
 
class Bar {
// Bar now has access to only Client::A and Client::B through the Attorney.
};
創作者介紹
創作者 hedgezzz 的頭像
hedgezzz

hedgezzz的部落格

hedgezzz 發表在 痞客邦 留言(0) 人氣()