title: C++ Stacks with multiple values
body: <p>I have some code below.  This code is a basic push/pop stack class that I have created as a template to enable someone to push/pop stacks.  I have a homework assignment and what I am trying to do now is create a stack that has multiple values.  </p>
  
  <p>So I want to be able to create a stack that basically can be sent three integers and where I can push/pop these as well.  What I am looking for is the theory on how this should work and I am not trying to get someone to do my homework for me.  </p>
  
  <p>The scenario is that we are dealing with parts.  So the user will put in the serial number (int), manufacture date (int), and lotnum (int).  So my questions are:</p>
  
  <ol>
  <li>When I "pop" the value should I attempt to send all three of the values during the pop or handle this another way?</li>
  <li><p>Should I try to create a new class using the struct like the class or something else?</p>
  
  <pre><code>/****************************************************************************
  Inventory class.
  
  Chad Peppers
  
  This class creates a object for stacking nodes
  
  In addition, there should be member functions to perform the following 
  operations:
  - Push to the stack
  - Pop to the stack
  - Function to check if empty
  
  ****************************************************************************/
  // Specification file for the DynIntStack class
  
  template &lt;class T&gt;
  class Inventory
  {
  private:
     // Structure for stack nodes
     struct StackNode
     {
        T value;        // Value in the node
        StackNode *next;  // Pointer to the next node
     };
  
     StackNode *top;      // Pointer to the stack top
  
  public:
     // Constructor
     Inventory()
        {  top = NULL; }
  
     // Destructor
     ~Inventory();
  
     // Stack operations
     void push(T);
     void pop(T &amp;);
     bool isEmpty();
  }; 
  
  /*************************************************************************
  Basic class constructor.
  
  Input Parameters:  Information to build the  stack
  
  Return Type:  void
  
  *************************************************************************/
  
  template&lt;class T&gt;
  Inventory&lt;T&gt;::~Inventory()
  {
     StackNode *nodePtr, *nextNode;
  
     // Position nodePtr at the top of the stack.
     nodePtr = top;
  
     // Traverse the list deleting each node.
     while (nodePtr != NULL)
     {
        nextNode = nodePtr-&gt;next;
        delete nodePtr;
        nodePtr = nextNode;
     }
  }
  
  /*************************************************************************
  Function to push an item in the stack
  
  Input Parameters:  T
  
  Return Type:  void
  
  *************************************************************************/
  
  template&lt;class T&gt;
  void Inventory&lt;T&gt;::push(T num)
  {
     StackNode *newNode; // Pointer to a new node
  
     // Allocate a new node and store num there.
     newNode = new StackNode;
     newNode-&gt;value = num;
  
     // If there are no nodes in the list
     // make newNode the first node.
     if (isEmpty())
     {
        top = newNode;
        newNode-&gt;next = NULL;
     }
     else  // Otherwise, insert NewNode before top.
     {
        newNode-&gt;next = top;
        top = newNode;
     }
  }
  
  /*************************************************************************
  Function to pop an item in the stack
  
  Input Parameters:  T
  
  Return Type:  void
  
  *************************************************************************/
  template&lt;class T&gt;
  void Inventory&lt;T&gt;::pop(T &amp;num)
  {
     StackNode *temp; // Temporary pointer
  
     // First make sure the stack isn't empty.
     if (isEmpty())
     {
        cout &lt;&lt; "The stack is empty.\n";
     }
     else  // pop value off top of stack
     {
        num = top-&gt;value;
        temp = top-&gt;next;
        delete top;
        top = temp;
     }
  }
  
  /*************************************************************************
  Basic class deconstructor.
  
  Input Parameters:  None
  
  Return Type:  void
  
  *************************************************************************/
  template&lt;class T&gt;
  bool Inventory&lt;T&gt;::isEmpty()
  {
     bool status;
  
     if (!top)
        status = true;
     else
        status = false;
  
     return status;
  }
  </code></pre></li>
  </ol>