title: Popping the top 2 values from a stack, adding them and push them back
body: <p>Here's what I came up with, I just want the program to pop the first 2 values in the stack, calculate them and push the back into the stack...I've already created the functions required but there seem to be a problem with the function that adds the two numbers.</p>
  
  <pre><code>#include &lt;iostream&gt;   
  
  using namespace std;
  int Maxlenght=5;
  class stackhouse{
  private:
      int *CreateArray;
      int top;
  public:
      stackhouse();
      bool IsEmpty();
      bool IsFull();
      void constructor();
      void Push(int);
      void Pop(int);
      void Sum();
      void Sub();
  };
  stackhouse::stackhouse(){
      CreateArray= new int[Maxlenght];
      top=-1;
  }
  bool stackhouse::IsEmpty()
  {
      if (top==-1) return 1;
      else return 0;
  }
  bool stackhouse::IsFull(){
      if (top==Maxlenght-1) return 1;
      else return 0;
  }
  void stackhouse::Push(int number){
      top++;
      CreateArray[top]=number;
  }
  void stackhouse::Pop (int number){
      number=CreateArray[top];
      top--;
  }
  void stackhouse::Sum(){
      int number=7,sum=5;
      Pop(sum);
      Pop(number);
      sum+=number;
      Push(sum);
      cout&lt;&lt;sum;
  }
  void main(){
      int number;
      stackhouse stack1;
      stackhouse();
      cout&lt;&lt;"Please fill the stack...";
      stack1.Push(5);
      stack1.Push(2);
      cout&lt;&lt;"The sum is...";
      stack1.Sum();
  }
  </code></pre>