摘要: 看一段代码: 1 #include <iostream> 2 #include <string> 3 using namespace std; 4 5 class CParent { 6 public: 7 CParent() { cout << "CParent::CParent()\r\n"; 阅读全文
posted @ 2020-10-16 17:46 朱果果 阅读(130) 评论(0) 推荐(0) 编辑
摘要: 设计模式 -- 把简单的代码复杂化 -- 方便后期维护 单例模式: 一般情况下,用户可以通过类构造很多个对象 1 #include <iostream> 2 #include <string> 3 using namespace std; 4 5 class Singleton { 6 public 阅读全文
posted @ 2020-10-16 15:27 朱果果 阅读(349) 评论(0) 推荐(0) 编辑
摘要: 静态成员变量: 1、要单独的把实现写在类外(cpp) 2、默认会用0对该成员进行初始化 3、静态成员变量是同一个类的不同对象共用的 4、本质上是一个带类域的全局变量(CInterger::m_static = 1;) #include <iostream> #include <string> usi 阅读全文
posted @ 2020-10-16 11:56 朱果果 阅读(208) 评论(0) 推荐(0) 编辑