7. Inbuilt stack STL #
Created Wednesday 22 January 2020
- Stacks and has are already been implemented in C++ STL.
- We will learn to use it.
- It’s better that we use .h now. We do this so as to avoid making main() inside the .h, as this is not allowed.
- If we write “something”.h, the header is in the directory of the main file. For anywhere else, specify the complete address or use . and … if that does the job.
- Inbuilt headers are included using <>
For stacks header is:
- What we have implemented is more or less the same. The interface is:
- stack is the name of the class Stack.
- push() is the same , i.e void push(T element);
- pop() is different, it is a void.
- top() is the same. returns the element on the top.
- empty() is the changed name in STL, same as our implementation.
- size() is the same.
Note: There’s no need for any other thing execpt that told here.