Design/iterator/main.cpp

22 lines
498 B
C++
Raw Normal View History

2024-10-28 14:07:29 +08:00
/*
* @Description:
* @version:
* @Author:
* @Date: 2023-10-31 08:43:58
* @LastEditors:
* @LastEditTime: 2023-10-31 08:55:57
*/
#include "Iterator.hpp"
// 客户端代码
int main() {
BookShelf* bookShelf = new BookShelf();
bookShelf->addBook(new DesignPatternsBook());
bookShelf->addBook(new RefactoringBook());
Iterator* it = bookShelf->createIterator();
while (it->hasNext()) {
Book* book = it->next();
cout << book->getName() << endl;
}
return 0;
}