-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathmain.cpp
39 lines (33 loc) · 855 Bytes
/
main.cpp
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
#include <iostream>
#include <cassert>
#include "bigthing_t.h"
#include "list_t.h"
using namespace std;
int main(int argc, char *argv[])
{
List l;
cout << "l insert 5 at the front. l is" << endl;
BigThing *a = new BigThing(5); // Must dynamically allocate the object
l.insert(a);
l.print();
// l is (5)
List ll;
cout << "ll insert 4 at the front. ll is" << endl;
BigThing *b = new BigThing(4);
ll.insert(b);
// ll is (4)
ll.print();
cout << "Assign ll as a copy of l. ll is" << endl;
ll = l; // call assignment operator
// ll is (5)
ll.print();
cout << "ll insert 3 at the front. ll is" << endl;
BigThing *c = new BigThing(3);
ll.insert(c);
ll.print();
cout << "Remove the front of ll. ll is" << endl;
BigThing *d = ll.remove();
delete d; // Must delete d!
ll.print();
return 0;
}