Computer Science, asked by Ujjwal6904, 1 year ago

Friend class in c plus plus can i access which members of the class whuch is declared as friend

Answers

Answered by trshukla
0
Friend Class A friend class can access private and protected members of other class in which it is declared as friend. It is sometimes useful to allow a particular class to access private members of other class. For example a LinkedList class may be allowed to access private members of Node.

class Node

{

private:

  int key;

  Node *next;

  /* Other members of Node Class */

  

  friend class LinkedList; // Now class  LinkedList can 

                           // access private members of Node

};

Similar questions