title: Initializing private struct variable inside main
body: <p>I want to initialize struct member variable(privately, I do not want to have a global struct, it will be easy but not so good). I have searched for it in StackOverflow but I have not found any useful solution for this problem.</p>
  
  <pre><code>#include &lt;iostream&gt;
  using namespace std;
  
  struct node
  {
      int data;
      node *next;
  };
  
  class linked_list
  {
  private:
      node internal;
  public:
      linked_list()
      {
      }
      linked_list(const linked_list &amp;);
  
      void push(node *head, int m_data);
      void printList(node *head);
      void swap(node *first, int x, int y);
  };
  
  void linked_list::push(node *head, int m_data)
  {
      node *newNode=new node;
      newNode-&gt;data=m_data;
      newNode-&gt;next=head;
      head=newNode;
  }
  
  void linked_list::printList(node *head)
  {
      while(head!=NULL)
      {
          cout&lt;&lt;head-&gt;data&lt;&lt;" ";
          head=head-&gt;next;
      }
  }
  
  void linked_list::swap(node *head, int x, int y)
  {
      if(x==y){ return;}
      node *prevX=NULL;
      node *currentX=head;
      while(currentX!=NULL &amp;&amp; currentX-&gt;data!=x)
      {
          prevX=currentX;
          currentX=currentX-&gt;next;
      }
  
      node *prevY=NULL;
      node *currentY=head;
      while(currentY!=NULL &amp;&amp; currentY-&gt;data!=y)
      {
          prevY=currentY;
          currentY=currentY-&gt;next;
      }
      if(currentX==NULL || currentY==NULL)
      {
          return;
      }
      if(prevX!=NULL)
      {
          prevX-&gt;next=currentY;
      }
      else
      {
          head=prevX;
      }
      if(prevY!=NULL)
      {
          prevY-&gt;next=currentX;
      }
      else
      {
          head=prevY;
      }
      node *temp=new node;
      temp=currentY-&gt;next;
      currentY-&gt;next=currentX-&gt;next;
      currentX-&gt;next=temp;
  }
  
  int main()
  {
      linked_list list;
      list.internal.head = NULL;
  
      /* The constructed linked list is:
       1-&gt;2-&gt;3-&gt;4-&gt;5-&gt;6-&gt;7 */
  
      list.push(&amp;head, 7);
      list.push(&amp;head, 6);
      list.push(&amp;head, 5);
      list.push(&amp;head, 4);
      list.push(&amp;head, 3);
      list.push(&amp;head, 2);
      list.push(&amp;head, 1);
  
      printf("\n Linked list before calling swapNodes() ");
      list.printList(&amp;head);
  
      list.swap(&amp;head, 4, 3);
  
     list.printList(&amp;head);
      return 0;
  }
  </code></pre>
  
  <p>I want this program to print given swapped elements linked list.</p>
  
  <p>Error: node linked_list::internal’ is private</p>