stack<int,vector<int>>s1
stack<int,list<int>>s1
stack<int>s1
Is there any advantage of using vector<int>
over the default stack version?
stack<int,vector<int>>s1
stack<int,list<int>>s1
stack<int>s1
Is there any advantage of using vector<int>
over the default stack version?
They are different constructors for setting up a stack STL.
stack<int> s1
Creates an empty stack ( with no elements inside ) , You need to push the int values into the stack manually after creating this.
stack<int,vector<int>>s1 stack<int,list<int>>s1
, Both of them initialises a stack , however you can directly assign the values of the stack by passing an already existing vector or list into that as
std::vector<int> a (2,20); // Creates a vector
std::stack<int,std::vector<int> > s1 (a); // initialises a stack with a vector
You can see the further page for more references http://www.cplusplus.com/reference/stack/stack/stack/