class Stack{
private:
struct Node{
int data;
Node* next;
};
Node* top;
int count;
public:
Stack():count(0),top(nullptr){}
void push(int data){
Node* node=new Node();
node->data=data;
node->next=top;
top=node;
count++;
}
void pop(){
if(isEmpty())return;
Node* node=top;
top=node->next;
delete node;
count--;
}
int mTop(){
return top->data;
}
bool isEmpty(){
return count==0;
}
};
int main(){
Stack* st=new Stack();
st->push(1);
st->push(2);
st->push(3);
}
3 2 1