From 27523dffefff908a776776331acf440aa364d22b Mon Sep 17 00:00:00 2001 From: salman2481 <55204448+salman2481@users.noreply.github.com> Date: Fri, 30 Oct 2020 14:43:24 +0500 Subject: [PATCH] Update linkList.cpp --- linkList.cpp | 62 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 62 insertions(+) diff --git a/linkList.cpp b/linkList.cpp index 5fd10eb..cab1435 100644 --- a/linkList.cpp +++ b/linkList.cpp @@ -234,3 +234,65 @@ int size =sizeof(number); return 0; } +#include +using namespace std; +class node +{ + int value; + node*nextnode; + int size; + public: + void setvalue(int m) + { + value=m; + } + void setnextnode(node *nn) + { + nextnode=nn; + } + int getvalue() + { + return value; + } + node *getnextnode() + { + return nextnode; + } +}; +class stack +{ + node *top; + int size; + public: + void push(int m) + { + if(size==0) + { + node *newnode=new node; + newnode->setvalue(m); + top->setnextnode(0); + top=newnode; + } + else + { + + node *newnode=new node; + newnode->setvalue(m); + newnode->setnextnode(top); + top=newnode; + + } + + } + + int pop() + { + + int x=top->getvalue(); + node *p=top; + top=top->getnextnode(); + delete p; + return x; + } + +};