-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstacklinkd.cpp
More file actions
91 lines (50 loc) · 1.17 KB
/
stacklinkd.cpp
File metadata and controls
91 lines (50 loc) · 1.17 KB
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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
// stacklinkd.cpp : This file contains the 'main' function. Program execution begins and ends there.
//
#include <iostream>
#include "linkedStackType.h"
using namespace std;
void testCopy(linkedStackType<int> OStack);
int main()
{
linkedStackType<int> stack;
int num;
stack.push(34);
stack.push(43);
stack.push(27);
while (!stack.isEmptyStack())
{
stack.pop(num);
cout << num << endl;
}
cout << endl;
linkedStackType<int> otherStack;
linkedStackType<int> newStack;
newStack = stack;
cout << "After the assignment operator, newStack";
while(!newStack.isEmptyStack())
{
newStack.pop(num);
cout << num << endl;
}
otherStack =stack;
cout << "Testing the copy constructor" << endl;
testCopy(otherStack);
cout << "After the copy costructor, otherStack: " << endl;
while (!otherStack.isEmptyStack())
{
otherStack.pop(num);
cout << num << endl;
}
system("pause");
return 0;
}
void testCopy(linkedStackType<int> OStack)
{
int num;
cout << "Stack in the function testCopy:" << endl;
while (!OStack.isEmptyStack())
{
OStack.pop(num);
cout << num << endl;
}
}