摘要: #include <iostream> // 可变模板参数 // 此例:可以构造可变数量,可变类型的函数输入。 // 摘自:https://www.cnblogs.com/qicosmos/p/4325949.html ///////////////////////////// using namespace std; //递归终止函数 void print() { cout << "empty" 阅读全文
posted @ 2019-12-01 21:21 路边的十元钱硬币 阅读(576) 评论(0) 推荐(0) 编辑
摘要: #include // 可变模板参数 // 此例:可以构造可变数量,可变类型的函数输入。 // 摘自:https://www.cnblogs.com/qicosmos/p/4325949.html ///////////////////////////// using namespace std; //递归终止函数 void print() { cout void print(T h... 阅读全文
posted @ 2019-12-01 21:16 路边的十元钱硬币 阅读(839) 评论(0) 推荐(0) 编辑
摘要: #include <iostream> // overloading "operator >> " outside class // >> 应该定义在类之外。 ////////////////////////////////////////////////////////// class Rectangle { public: Rectangle(int w, int h) : width(w), 阅读全文
posted @ 2019-12-01 16:27 路边的十元钱硬币 阅读(288) 评论(0) 推荐(0) 编辑
摘要: 虚函数的几点说明: 1. 当一个成员函数定义为虚函数时,其派生类中的同名函数也自动为虚函数。无论其是否添加了 virtual 关键字。 为了能良好的阅读代码,请加上。 2. 父类的虚函数,就是为了让子类中的同名成员函数覆盖。这样,父类对象的指针就可以指向子类对象,并调用子类的同名函数。 3. 纯虚函 阅读全文
posted @ 2019-12-01 15:42 路边的十元钱硬币 阅读(225) 评论(0) 推荐(0) 编辑
摘要: Stack 堆 存在于某作用域内的一块空间。说白了就是函数产生的空间,用于存放函数的变量、返回地址。 在函数体中声明的局部变量,就时存储在Stack中。 Heap 栈 由操作系统提供的全局空间。在程序结束后由系统释放。 定义的全局变量就在这个内存区域中。 静态数据区 static对象所在区域。 文字 阅读全文
posted @ 2019-12-01 15:27 路边的十元钱硬币 阅读(88) 评论(0) 推荐(0) 编辑
摘要: 类中含有 指针类型 的成员变量时,就必须要定义 copy ctor 和 copy op= copy ctor 请见: copy op= 请见: https://www.cnblogs.com/alexYuin/p/11965172.html 阅读全文
posted @ 2019-12-01 15:13 路边的十元钱硬币 阅读(326) 评论(0) 推荐(0) 编辑
摘要: 使用示例 阅读全文
posted @ 2019-12-01 15:02 路边的十元钱硬币 阅读(1182) 评论(0) 推荐(0) 编辑
摘要: #include <iostream> // overloading "operator + " // 要考虑加法的形式 // a+1 // a+a // 1+a ////////////////////////////////////////////////////////// class Rectangle { public: Rectangle(const int w, const int 阅读全文
posted @ 2019-12-01 14:33 路边的十元钱硬币 阅读(281) 评论(0) 推荐(0) 编辑
摘要: #include <iostream> // overloading "operator () " outside class ////////////////////////////////////////////////////////// class Rectangle { public: Rectangle(const int w, const int h) : width(w), hei 阅读全文
posted @ 2019-12-01 14:16 路边的十元钱硬币 阅读(232) 评论(0) 推荐(0) 编辑
摘要: #include // overloading "operator [] " inside class ////////////////////////////////////////////////////////// class Rectangle { public: Rectangle(const int w, const int h) : width(w), height... 阅读全文
posted @ 2019-12-01 12:51 路边的十元钱硬币 阅读(209) 评论(0) 推荐(0) 编辑
摘要: ++i,应该是先自加一,返回自身(已经加1之后的自身); i++,应该是先拷贝自身,再自加一,返回自身的拷贝(自己已经加1,但是拷贝没有)。 阅读全文
posted @ 2019-12-01 12:43 路边的十元钱硬币 阅读(263) 评论(0) 推荐(0) 编辑
摘要: ++i,应该是先自加一,返回自身(已经加1之后的自身); i++,应该是先拷贝自身,再自加一,返回自身的拷贝(自己已经加1,但是拷贝没有)。 阅读全文
posted @ 2019-12-01 11:32 路边的十元钱硬币 阅读(653) 评论(0) 推荐(0) 编辑
摘要: #include // overloading "operator << " outside class // << 应该定义在类之外。 ////////////////////////////////////////////////////////// class Rectangle { public: Rectangle(int w, int h) : width(w), h... 阅读全文
posted @ 2019-12-01 10:22 路边的十元钱硬币 阅读(383) 评论(0) 推荐(0) 编辑
摘要: #include // overloading "operator = " outside class // 是二元操作符 ////////////////////////////////////////////////////////// class Rectangle { public: Rectangle(int w, int h) : width(w), height(... 阅读全文
posted @ 2019-12-01 10:01 路边的十元钱硬币 阅读(3940) 评论(0) 推荐(0) 编辑
摘要: #include // overloading "operator = " inside class // = 是一元操作符。不写,编译器会提供 默认 拷贝赋值函数。可以通过显式“=delete”来禁用默认。对于复杂class的默认=可能会造成问题,请特别注意。 ////////////////////////////////////////////////////////// clas... 阅读全文
posted @ 2019-12-01 09:44 路边的十元钱硬币 阅读(497) 评论(0) 推荐(0) 编辑
摘要: #include <iostream> // overloading "operator == " outside class // == 是二元操作符 ////////////////////////////////////////////////////////// class Rectangle { public: Rectangle(int w, int h) : width(w), he 阅读全文
posted @ 2019-12-01 09:29 路边的十元钱硬币 阅读(320) 评论(0) 推荐(0) 编辑
摘要: #include // overloading "operator == " inside class // == 是二元操作符 ////////////////////////////////////////////////////////// class Rectangle { public: Rectangle(int w, int h) : width(w), heig... 阅读全文
posted @ 2019-12-01 09:25 路边的十元钱硬币 阅读(1114) 评论(0) 推荐(0) 编辑