How to push and pop an element into a stack if I declare the stack as stack > ?

stack<pair<int,int> > s;

s.push( pair<int,int>( a, b ) );
s.pop();
pair<int,int> p = s.top();

1 Like

You can push in this way : s.push(make_pair(5,7));.

Refer the discussion at => http://stackoverflow.com/a/2923088/1679643

A C++ code to implement it - Stack Code