 <p>You can define a class like this: </p> <pre><code>class Stack { private: int stack[MAX_STACK]; int MIN_STACK = 0; public: . . . } </code></pre> <p>The push function can be implemented as follows:</p> <p>When you increment the value of MIN_STACK before inserting, you always leave stack[0] empty and waste the space. Also use <code>MIN_STACK</code> as your index and not <code>MAX_STACK</code> as the value of <code>MAX_STACK</code> is always 10.</p> <pre><code>void PUSH(int val) { if(MIN_STACK &lt; MAX_STACK) { stack[MIN_STACK++] = val; /* Here MIN_STACK is incremented after insertion. It is the same as stack[MIN_STACK] = val; MIN_STACK +=1; */ } else cout &lt;&lt; "Full stack!" &lt;&lt; endl; } </code></pre> <p>In POP function, you have nothing to delete if <code>MIN_STACK</code> is 0 because each time you push a value <code>MIN_STACK</code> is incremented.<code>MIN_STACK</code> always points to the next free location. SO the data to be popped out is in <code>(MIN_STACK-1)</code>th position. So decrement the <code>MIN_PATH</code> and use it.</p> <pre><code>void POP() { int aux; if(MIN_STACK &gt; 0) { aux = stack[--MIN_STACK]; /* Here MIN_STACK is decremented before popping out. It is the same as MIN_STACK -= 1; aux = stack[MIN_STACK]; */ cout &lt;&lt; " POP : " &lt;&lt; aux &lt;&lt; endl; } else cout &lt;&lt; "Empty stack!" &lt;&lt; endl; } </code></pre> <p>In your <code>cpp</code> file create an object of the class as:</p> <pre><code>Stack S1; S1.PUSH(elm); S1.POP(); </code></pre>