Friend class

From Wikipedia, the free encyclopedia

In object-oriented programming to allow access to "private" or "protected" data of a class in another class, the latter class is declared as a friend class.

Contents

[edit] Purpose

A friend class has full access to the private data members of a class without being a member of that class.

[edit] Example

A friend class can be declared as shown:

class A
{
private:
   //...
public:
   //...
   friend class B;
}

[edit] See also

[edit] References

  • An introduction to object-oriented programming in c++ by Graham M. Seed

[edit] External links

http://www.cplusplus.com/doc/tutorial/