Question: Use simple C++. Implement a stack template class using a std::vector as underlying storage. Implement, push(), pop(), top(), and size(). Test using the given main()

Use simple C++. Implement a stack template class using a std::vector as underlying storage. Implement, push(), pop(), top(), and size(). Test using the given main()

#include

// Your stack class template class Stack { };

int main() { Stack s; s.push(1); s.push(2); s.push(3); s.push(1); s.push(2); s.push(3); s.pop(); s.pop(); s.push(5); s.pop(); s.pop(); s.pop(); // get the top (without popping) int x; s.top(x); std::cout << "The top is " << x << ". "; // 2 return 0; }

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!