10 2015 档案
摘要:创建型模型一、简单工厂模式靠 if else 或者 select case 等分支去控制不同对象的创建,难以维护二、工厂方法模式 Factory实现方式:将创建对象的方法定义成一个接口,通过多态的方式创建具体的类。 优点: 如果要添加一个新类,则不需要修改已有的代码。缺点:1.客户端需要知道基类和工厂类,耦合性差2.仅仅适合创建一种类三、 AbstactFactoryFactory的升级版,可以...
阅读全文
摘要:// sort.cpp : Defines the entry point for the console application.//#include "stdafx.h"#include using namespace std;void print ( int a[] ,int n ){ for ( int i=0;i a[j] ) { int tmp = a[i]; a[i] =...
阅读全文
摘要:// sort.cpp : Defines the entry point for the console application.//#include "stdafx.h"#include using namespace std;void print ( int a[] ,int n ){ for ( int i=0;i a[j] ) { int tmp = a[i]; a[i] =...
阅读全文
摘要:// list.cpp : Defines the entry point for the console application.//#include "stdafx.h"#include using namespace std;typedef struct list_node { int data; list_node *left; list_node *right;} Node;Node *...
阅读全文
摘要:// BTree.cpp : Defines the entry point for the console application.//#include "stdafx.h"#include #include using namespace std;typedef struct BTree_node { int data ; BTree_node * left; BTree_node * rig...
阅读全文