get data in stack c++ code example
Example 1: stack c++
stack<int> stk;
stk.push(5);
int ans = stk.top(5); // ans =5
stk.pop();//removes 5
Example 2: c++ insertion in astack
stack<int> a;
a.push(5);
a.push(6);
//.....
stack<int> stk;
stk.push(5);
int ans = stk.top(5); // ans =5
stk.pop();//removes 5
stack<int> a;
a.push(5);
a.push(6);
//.....