#include <bits/stdc++.h> using namespace std; struct StackNode { int data; StackNode *next; StackNode(int a) { data = a; next = NULL; } }; class MyStack { private: StackNode *top; public: void push(int); int pop(); MyStack() { top = NULL; } }; //Function to push an integer into the stack. void MyStack ::push(int x) { StackNode* newnode=new StackNode(x); newnode->next=top; top=newnode; } //Function to remove an item from top of the stack. int MyStack ::pop() { int ddata; if(top==NULL) { return -1; } ddata=top->data; top=top->next; return ddata; }