-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathIntCollectionProgram.cpp
More file actions
69 lines (50 loc) · 1.43 KB
/
Copy pathIntCollectionProgram.cpp
File metadata and controls
69 lines (50 loc) · 1.43 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
//Amelie Cameron Assignment 11
//In this program I added a copy constructor and three overloaded operators( = , == , and << ) to the IntCollection class(a dynamic storage mechanism for storing integers.)
#include "IntCollection.h"
#include <iostream>
using namespace std;
void print_collection(IntCollection &c) {
for(int i = 0; i < c.getSize(); i++)
{
cout << c.get(i) << endl;
}
}
int main()
{
IntCollection c;
cout << "Testing insertion operator" << endl;
c << 45;
c << -210;
c << 77;
c << 102;
c << -39;
cout << "IntCollection c : " << endl;
print_collection(c);
cout << "Size is " << c.getSize() << endl;
cout << "Testing insertion operator END" << endl;
cout << endl;
cout << "Testing copy constructor (c to b)" << endl;
IntCollection b = c;
cout << "IntCollection b : " << endl;
print_collection(b);
cout << "Testing copy constructor END" << endl;
cout << endl;
cout << "Testing equals operator" << endl;
cout << "true if c and b are the same, false if different" << endl;
if(b == c)
{
cout << "true" << endl;
}
else
cout << "false" << endl;
cout << "Testing equals operator END" << endl;
cout << endl;
cout << "Testing assignment operator (c to d)" << endl;
IntCollection d;
d = c;
cout << "IntCollection d : " << endl;
print_collection(d);
cout << "Testing assignment operator END" << endl;
cout << endl;
return 0;
}