title: Access friend class's private member
body: <p>I'm trying to write a console application like Twitter. User and UserList classes including each other. I'm trying to access to following user's followers. UserList class is used for linked list.</p>
  
  <pre><code>//User.h
  
  #pragma once
  
  #include &lt;iostream&gt;
  #include &lt;string&gt;
  
  using namespace std;
  
  class UserList;
  class User
  {
     friend class UserList;
  private:
     string userName;
     string personalComment;
     UserList *followed;
     UserList *following;
     int followedNumber;
     int followingNumber;
     //TWEET
     UserList *blocked;
     User* next;
  public:
     User();
     User(string&amp;,string&amp;);
  };
  
  //UserList.h
  #pragma once
  
  #include &lt;iostream&gt;
  #include &lt;string&gt;
  
  using namespace std;
  
  
  class User;
  
  class UserList{
  private:
      User *root;
  public:
      UserList();
      ~UserList();
      void addUser(string&amp;,string&amp;);
      bool checkUser(string&amp;);
      User&amp; findUser(string&amp;);
      void printList();
  };
  </code></pre>
  
  <p>Firstly, I wrote a function to find following user.</p>
  
  <pre><code>//userList.cpp
  User&amp; UserList::findUser(string&amp; name)
  {
     User *temp=root;
     while(temp!=NULL)
     {
         if(!name.compare(temp-&gt;userName))
         {
              return temp;
         }
         temp= temp-&gt;next;
      }
      temp= temp-&gt;next;
      return temp;
  }
  </code></pre>
  
  <p>For example user1 wants to follow user2. I want to check does user1 already follow user2.( checkUser(username) looks for a user in a list and return bool)</p>
  
  <pre><code>//main.cpp in main()
  if(users.findUser(user1name).following-&gt;checkUser(user2name))
  {
              cout&lt;&lt;"Err: The user '"&lt;&lt; user1name &lt;&lt; "' has already followed '"&lt;&lt;user2name&lt;&lt;"'!"&lt;&lt;endl;
  } 
  </code></pre>
  
  <p>But there is a "UserList* User::following is private" error and "within this context"</p>
  
  <p>How can I access this user's lists?</p>