forked from jaredtao/DesignPattern
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
27 lines (26 loc) · 670 Bytes
/
main.cpp
File metadata and controls
27 lines (26 loc) · 670 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
#include "Book.h"
#include "BookSelf.h"
#include "BookSelfIterator.h"
#include <iostream>
#include <string>
using std::cerr;
using std::cout;
using std::endl;
using std::string;
int main()
{
Aggregate<Book> *aggregate = new BookSelf<Book>(0);
BookSelf<Book> *self = static_cast<BookSelf<Book> *>(aggregate);
self->appendBoox(Book(string("name1")));
self->appendBoox(Book(string("name2")));
self->appendBoox(Book(string("name3")));
auto itor = aggregate->CreateIterator();
while (itor->hasNext())
{
Book book = itor->next();
cout << book.GetName() << endl;
}
delete aggregate;
delete itor;
return 0;
}