-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathmain.cpp
More file actions
48 lines (37 loc) · 1.06 KB
/
main.cpp
File metadata and controls
48 lines (37 loc) · 1.06 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
// compile: clang++ -o main main.cpp book.cpp person.cpp
#include "person.hpp"
#include "book.hpp"
#include <iostream>
using namespace std;
int main(int argc, char* argv[]) {
Book b;
Person *p1 = new Person();
p1->firstname("Arthur");
p1->lastname("Clarke");
p1->birthday(-1642381200); // 1917-12-16
b.add(p1);
Person *p2 = new Person();
p2->firstname("Peter");
p2->lastname("Hamilton");
p2->birthday(-310352400); // 1960-03-02
b.add(p2);
Person *p3 = new Person();
p3->firstname("Cory");
p3->lastname("Doctorow");
p3->birthday(48553200); // 1971-07-17
b.add(p3);
Person *p4 = new Person();
p4->firstname("Charlie");
p4->lastname("Stross");
p4->birthday(-164221200); // 1964-10-18
b.add(p4);
for(size_t i=0; i<b.size(); ++i) {
Person *p = b[i];
cout << p->to_str() << endl;
}
cout << "Looking for Peter" << endl;
Person *p5 = b.lookup("Peter");
cout << p5->to_str() << endl;
b.remove(1);
cout << "After remove: " << b.size() << endl;
}