摘要:
1 #ifndef STACK_H 2 #define STACK_H 3 4 #include<stdexcept> 5 #include<string> 6 using namespace std; 7 8 template<typename T> 9 class Stack10 {11 private:12 template<typename T>13 struct Node14 {15 T data;16 Node* next;17 Node(T data,Node* next):data(data),nex... 阅读全文
posted @ 2012-06-25 21:55
freewater
阅读(504)
评论(0)
推荐(0)
摘要:
写了一个单链表的模板,欢迎大家批评指正。 1 #ifndef LINKEDLIST_H 2 #define LINKEDLIST_H 3 #define DEBUG 4 5 #include<iostream> 6 using namespace std; 7 8 template <typename T> 9 class LinkedList 10 { 11 public: 12 template<typename T> 13 struct Node 14 { 15 T data; 16 Node* next; 1... 阅读全文
posted @ 2012-06-25 21:54
freewater
阅读(208)
评论(0)
推荐(0)
摘要:
1 #ifndef FACTORYMETHOD_H 2 #define FACTORYMETHOD_H 3 4 #include<iostream> 5 using namespace std; 6 7 class Product//should be a pure virtual class. 8 { 9 public:10 Product(){}11 ~Product(){}12 };13 14 class ConcreteProductA:public Product15 {16 public:17 ConcreteProductA()18 {19 ... 阅读全文
posted @ 2012-06-25 15:45
freewater
阅读(331)
评论(0)
推荐(0)
摘要:
装饰者模式(Decorator Pattern):动态地给一个对象添加一些额外的职责,就增加功能来说,装饰者模式比生成子类更加灵活。 1 #ifndef DECORATOR_H 2 #define DECORATOR_H 3 4 #include<iostream> 5 using namespace std; 6 7 class Component 8 { 9 public:10 virtual void operation()=0;11 };12 13 class ConcreteComponent:public Component14 {15 public:16 vo... 阅读全文
posted @ 2012-06-25 13:53
freewater
阅读(181)
评论(0)
推荐(0)

浙公网安备 33010602011771号