forked from CSUF-CPSC-131-Fall2019/Data-Structures-Code
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathStackLinkedList_main.cpp
More file actions
40 lines (29 loc) · 946 Bytes
/
StackLinkedList_main.cpp
File metadata and controls
40 lines (29 loc) · 946 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
37
38
39
40
#include <iostream>
#include <stdexcept>
#include "StackLinkedList.hpp"
using std::cout;
using std::endl;
int main() {
StackLinkedList<int> myStack;
cout << "Pushing 10 ..." << endl;
myStack.push(10);
cout << "Top of stack: " << myStack.peek() << endl;
cout << "Pushing 20 ..." << endl;
myStack.push(20);
cout << "Top of stack: " << myStack.peek() << endl;
cout << "Pushing 30 ..." << endl;
myStack.push(30);
cout << "Top of stack: " << myStack.peek() << endl;
cout << "Popping ..." << endl;
myStack.pop();
cout << "Top of stack: " << myStack.peek() << endl;
cout << "Popping ..." << endl;
myStack.pop();
cout << "Top of stack: " << myStack.peek() << endl;
cout << "Popping ..." << endl;
myStack.pop();
if (myStack.empty())
cout << "Stack is empty" << endl;
else
cout << "Stack is not empty" << endl;
}