05 2020 档案
摘要:使用const Complex operator + (const Complex &c ) const {} 重新定义类的+操作 #include<iostream> using namespace std; class Complex{ public: Complex(int r, int i)
阅读全文
摘要:使用void(Student::*pwho) void = & Student::who // 构造函数指针 使用string Student::*p_name = & Student::m_name //构造变量指针 #include <iostream> #include <cstdio> us
阅读全文
摘要:饿汉式声明, 一开始的时候对单例进行声明 #include <iostream> using namespace std; class Singleton{ public: static Singleton& getInstance(void){ return s_instance; } void
阅读全文
摘要:静态变量 使用static 来定义变量,可以被全局的类使用,不需要声明就能调用,属于类成员,不属于对象成员 #include <iostream> using namespace std; class A{ public: //普通成员变量在构造时定义和初始化 A(int data = 0):m_d
阅读全文