【1】什么是迭代器模式?
【2】迭代器模式代码示例:
代码示例:
1 #include <iostream>
2 #include <string>
3 using namespace std;
4
5 class Iterator;
6
7 class Aggregate
8 {
9 public:
10 virtual Iterator *createIterator() = 0;
11 };
12
13 class Iterator
14 {
15 public:
16 virtual void first() = 0;
17 virtual void next() = 0;
18 virtual bool isDone() = 0;
19 };
20
21 class ConcreteAggregate : public Iterator
22 {
23 public:
24 void first()
25 {}
26 void next()
27 {}
28 bool isDone()
29 {}
30 };
31
32 int main()
33 {
34 return 0;
35 }
Good Good Study, Day Day Up.
顺序 选择 循环 总结