-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathSTLstack.cpp
More file actions
36 lines (29 loc) · 765 Bytes
/
STLstack.cpp
File metadata and controls
36 lines (29 loc) · 765 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
#include<cstdio>
#include<stack>
using namespace std;//wjthout this line, you must use"std::stack<type>" instead of using "stack<type>"
int main()
{
stack<int> intStack;
// same as InitializeStack(intStack)
// syntax = stack<type> name;
intStack.push(1);
// same as Push(intStack,1);
// syntax = name.push(value);
intStack.pop();
// same as Pop(intStack);
// syntax = name.pop()
// ***this is void function
intStack.top();
// same as Top(intStack);
// syntax = name.top();
intStack.empty();
// same as IsEmpty(intStack);
// syntax = name.empty();
// return true if stack's size is 0, false otherwise.
//STL stack never full = not have IsFull :P
//but it still can underflow
intStack.size();
// return size of stack
//
return 0;
}