title: using structure instead of class
body: <p>I have never learned class but I do get the general idea and I'm trying it out.
  The following code found online, making stacks using linked list and I'm wondering if we used structure instead of class what would this program look like?</p>
  
  <pre><code>#include&lt;iostream&gt;
  using namespace std;
  
  
  //   Creating a NODE Structure
  struct node
  {
  int data;
  struct node *next;
  };
  
  // Creating a class STACK
  class stack
  {
  struct node *top;
  public:
  stack() // constructure
  {
      top=NULL;
  }
  void push(); // to insert an element
  void pop();  // to delete an element
  void show(); // to show the stack
  };
  // PUSH Operation
  void stack::push()
  {
  int value;
  struct node *ptr;
  cout&lt;&lt;"nPUSH Operationn";
  cout&lt;&lt;"Enter a number to insert: ";
  cin&gt;&gt;value;
  ptr=new node;
  ptr-&gt;data=value;
  ptr-&gt;next=NULL;
  if(top!=NULL)
      ptr-&gt;next=top;
  top=ptr;
  cout&lt;&lt;"nNew item is inserted to the stack!!!";
  
  }
  
  // POP Operation
  void stack::pop()
  {
   struct node *temp;
   if(top==NULL)
   {
      cout&lt;&lt;"nThe stack is empty!!!";
   }
   temp=top;
   top=top-&gt;next;
   cout&lt;&lt;"nPOP Operation........nPoped value is "&lt;&lt;temp-&gt;data;
   delete temp;
   }
  
  // Show stack
  void stack::show()
  {
  struct node *ptr1=top;
  cout&lt;&lt;"nThe stack isn";
  while(ptr1!=NULL)
  {
      cout&lt;&lt;ptr1-&gt;data&lt;&lt;" -&gt;";
      ptr1=ptr1-&gt;next;
  }
  cout&lt;&lt;"NULLn";
  }
  
  // Main function
  int main()
  {
  stack s;
  int choice;
  while(1)
  {
      cout&lt;&lt;"n-----------------------------------------------------------";
      cout&lt;&lt;"nttSTACK USING LINKED LISTnn";
      cout&lt;&lt;"1:PUSHn2:POPn3:DISPLAY STACKn4:EXIT";
      cout&lt;&lt;"nEnter your choice(1-4): ";
      cin&gt;&gt;choice;
      switch(choice)
      {
          case 1:
              s.push();
              break;
          case 2:
              s.pop();
              break;
          case 3:
              s.show();
              break;
          case 4:
              return 0;
              break;
          default:
              cout&lt;&lt;"Please enter correct choice(1-4)!!";
              break;
       }
    }
    return 0;
  }
  </code></pre>
  
  <p>Just wondering what would this code look like if we were to use a structure instead of class? </p>