1】什么是模板方法模式?又叫模板方法模式,在一个方法中定义一个算法的骨架,而将一些步骤延迟到子类中。模板方法使得子类可以在不改变算法结构的情冴下,重新定义算法中的某些步骤。【2】模板方法模式代码示例:代码示例1:#include #include using namespace std;class ...
                            
                            
                                分类:
其他好文   时间:
2015-05-28 00:32:54   
                                阅读次数:
106
                             
                    
                        
                            
                            
                                【1】什么是迭代器模式?【2】迭代器模式代码示例:代码示例:#include #include using namespace std;class Iterator;class Aggregate{public: virtual Iterator *createIterator() = 0;}...
                            
                            
                                分类:
其他好文   时间:
2015-05-28 00:30:32   
                                阅读次数:
99
                             
                    
                        
                            
                            
                                【1】什么是建造者模式?将一个复杂对象的构建与它的表示分离,使得同样的构建过程可以创建不同的表示。【2】建造者模式代码示例:代码示例1:#include #include #include using namespace std;class Person{public: virtual voi...
                            
                            
                                分类:
其他好文   时间:
2015-05-28 00:27:06   
                                阅读次数:
95
                             
                    
                        
                            
                            
                                【1】什么是组合模式?将对象组合成树形结构以表示“部分整体”的层次结构。组合模式使得用户对单个对象和组合对象的使用具有一致性。【2】组合模式代码示例:代码示例:#include #include #include using namespace std;class Component{public:...
                            
                            
                                分类:
其他好文   时间:
2015-05-28 00:21:19   
                                阅读次数:
133
                             
                    
                        
                            
                            
                                【1】什么是适配器模式?将一个类的接口转换成客户希望的另外一个接口。Adapter模式使得原本由于接口不兼容而不能一起工作的那些类可以在一起工作。【2】适配器模式的代码示例:代码示例如下1:#include #include using namespace std;class Adaptee{pub...
                            
                            
                                分类:
其他好文   时间:
2015-05-28 00:19:18   
                                阅读次数:
170
                             
                    
                        
                            
                            
                                1. 评论在数据库中的表示app/models.py: Comment 模型class Comment(db.Model): __tablename__ = 'comments' id = db.Column(db.Integer, primary_key=True) body =...
                            
                            
                                分类:
其他好文   时间:
2015-05-28 00:15:26   
                                阅读次数:
305
                             
                    
                        
                            
                            
                                namespace 计算器2._0{ public partial class Form1 : Form { public Form1() { InitializeComponent(); } private ...
                            
                            
                         
                    
                        
                            
                            
                                1 class A 2 { 3 public static final int VAL = 3; // 不会导致A被加载 4 static 5 { 6 System.out.println("load A"); 7 } 8 public A(...
                            
                            
                                分类:
编程语言   时间:
2015-05-28 00:15:14   
                                阅读次数:
166
                             
                    
                        
                            
                            
                                【1】什么是状态模式?不同的状态,不同的行为。或者说,每个状态有着相应的行为。【2】状态模式的代码示例:代码示例:#include #include using namespace std;class Work;class State;class ForenonnState;class State{...
                            
                            
                                分类:
其他好文   时间:
2015-05-28 00:14:53   
                                阅读次数:
161
                             
                    
                        
                            
                            
                                1 public class test1 : MonoBehaviour { 2 3 public GameObject prefab; 4 5 void Start() 6 { 7 for (int i = 0; i ().material.color...
                            
                            
                                分类:
编程语言   时间:
2015-05-28 00:13:43   
                                阅读次数:
227