摘要: 适配器模式 代理模式 区别在于被替代的类是否继承于subject 再上一个通俗易懂的版本 适配器模式:小刘去美国旅游,想代购化妆品回国但是对当地语言不通,于是请当地人山姆代替她买商品。 代理模式:小刘刚刚移民美国,由于太忙没有时间,于是请当地人山姆代替她买商品。 区别就是:小刘是不是美国人!即是否继 阅读全文
posted @ 2018-11-15 10:29 aote369 阅读(3259) 评论(0) 推荐(0) 编辑
摘要: //观察者模式 class Observer{ public: virtual void Updata() = 0; }; class Subject{ public: void Attach(Observer* in){ m_list.push_back(in); } void Detach(Observer* out){ m_list.remove(out); } ... 阅读全文
posted @ 2018-10-01 16:26 aote369 阅读(144) 评论(0) 推荐(0) 编辑
摘要: void(*function)(float); void One(float one){ cout << one << endl; } void Two(float two){ cout << two << endl; } void Three(float three){ cout << three << endl; } int main(){ function ... 阅读全文
posted @ 2018-09-09 21:43 aote369 阅读(135) 评论(0) 推荐(0) 编辑
摘要: 1、在类所有实例中静态成员变量和静态成员函数都只有一份拷贝 2、静态成员函数不能调用非静态成员,非静态成员函数可以调用静态成员 3、静态成员变量在使用前要初始化 一、静态成员变量的访问 二、静态成员函数的访问 阅读全文
posted @ 2018-08-30 17:03 aote369 阅读(1054) 评论(0) 推荐(0) 编辑
摘要: union { short int i; char x[2]; }a; void main() { cout << sizeof(a) << endl; //自然顺序3210 a.x[1] = 0x11; a.x[0] = 0x00; printf("%x\n", a.i); a.i = 0x1100; printf("%x\n"... 阅读全文
posted @ 2018-08-29 09:19 aote369 阅读(261) 评论(0) 推荐(0) 编辑
摘要: const char* 1、字符串相对于指针是常量,但字符串本身不是常量 2、指针能够被重定向 char* const 1、指针不能够被重定向 另外:char const*=const char* 阅读全文
posted @ 2018-08-29 08:31 aote369 阅读(1001) 评论(0) 推荐(0) 编辑
摘要: int main() { stack test; //插入 test.push(1); test.push(2); test.push(3); //删除 test.pop(); cout << test.size() << endl; while (!test.empty()){//清空栈 test.pop(... 阅读全文
posted @ 2018-08-24 15:55 aote369 阅读(131) 评论(0) 推荐(0) 编辑
摘要: int main() { set test; //插入 test.insert(2); test.insert(1); test.insert(4); test.insert(5); test.insert(3); //遍历 for (auto i : test) cout << i << endl; ... 阅读全文
posted @ 2018-08-24 15:31 aote369 阅读(4449) 评论(1) 推荐(0) 编辑
摘要: int main() { vector test; //插入 test.push_back(0); test.insert(test.begin(),1);//在迭代器之前插入 test.insert(test.end(), 3, 2); //遍历 for (auto i : test) cout << i << " "; ... 阅读全文
posted @ 2018-08-24 10:59 aote369 阅读(1156) 评论(0) 推荐(0) 编辑
摘要: int main() { list test; //插入 test.push_back(1); test.push_back(1); test.push_front(0); test.push_back(2); auto it = test.begin(); for (int count = 0; it != test.e... 阅读全文
posted @ 2018-08-24 10:03 aote369 阅读(1822) 评论(0) 推荐(0) 编辑