上一页 1 ··· 25 26 27 28 29 30 31 32 33 ··· 68 下一页
摘要: 1 #include 2 #include 3 using namespace std; 4 5 class myclass 6 { 7 public: 8 //static只会初始化一次 9 static int num; 10 myclass() 11 { 12 num += 1; 13 } 14 ~my... 阅读全文
posted @ 2018-03-17 23:39 喵小喵~ 阅读(129) 评论(0) 推荐(0) 编辑
摘要: 类中可以包含引用成员,但必须在定义变量的时候默认初始化 引用作用域参数和返回值,避免内存占用 常引用等价于常对象 常引用等价于常对象 完整代码 阅读全文
posted @ 2018-03-17 23:26 喵小喵~ 阅读(109) 评论(0) 推荐(0) 编辑
摘要: 1 #include 2 using namespace std; 3 4 struct point 5 { 6 int a; 7 int b; 8 }; 9 10 class myclass 11 { 12 public: 13 int x; 14 int y; 15 myclass(int n):x(n),y(n) 16 ... 阅读全文
posted @ 2018-03-17 23:11 喵小喵~ 阅读(81) 评论(0) 推荐(0) 编辑
摘要: 1 #define _CRT_SECURE_NO_WARNINGS 2 #include 3 #include 4 using namespace std; 5 6 //默认拷贝构造只是值传递,对于数据有效,对于指针则是同一个指向,需要重写一下拷贝构造 7 //类的内部有指针分配内存,需要深拷贝,否则需要浅拷贝 8 class mystring 9 { 10 public... 阅读全文
posted @ 2018-03-17 23:03 喵小喵~ 阅读(97) 评论(0) 推荐(0) 编辑
摘要: 1 #include 2 using namespace std; 3 4 class myclass 5 { 6 public: 7 int x; 8 int y; 9 public: 10 myclass() = default; 11 //拷贝构造 12 //myclass(const myclass &my) = defaul... 阅读全文
posted @ 2018-03-17 22:45 喵小喵~ 阅读(108) 评论(0) 推荐(0) 编辑
摘要: const常量对象,无法改变数据,只能引用尾部带const方法 类的成员如果是const,可以默认初始化,也可以构造的初始化,不可在构造函数内部初始化 类中的const成员,无法直接修改,可以间接修改 类的成员函数const三种情形:1.返回值const,2.返回常量,3.参数const,可读不可写 阅读全文
posted @ 2018-03-17 17:23 喵小喵~ 阅读(162) 评论(1) 推荐(0) 编辑
摘要: 1 #include "mainwindow.h" 2 #include 3 4 //创建一个MainWindow类 5 class myclass 6 { 7 private: 8 MainWindow *p; 9 //初始化内存 10 myclass(int i) 11 { 12 p = new MainWindow[i]... 阅读全文
posted @ 2018-03-16 22:50 喵小喵~ 阅读(199) 评论(0) 推荐(0) 编辑
摘要: 1 #include 2 using namespace std; 3 4 //myclass类 5 class myclass 6 { 7 public: 8 int add(int a, int b) 9 { 10 return a + b; 11 } 12 int sub(int a, int b) 13 { 1... 阅读全文
posted @ 2018-03-16 20:04 喵小喵~ 阅读(155) 评论(0) 推荐(0) 编辑
摘要: 设置断点调试 在一行代码的左侧点击即可设置断点,按F5(调试->开始调试)即可运行到第一个端点处暂停 逐语句调试 按F11(调试->逐语句)即可开始一步一步执行 逐过程调试 按F10(调试->逐过程)开始逐过程调试,此方法不会进入调用的函数里面 原文此处的 Step into a property 阅读全文
posted @ 2018-03-16 19:02 喵小喵~ 阅读(163) 评论(0) 推荐(0) 编辑
摘要: 1 #include 2 using namespace std; 3 4 class myclass 5 { 6 public: 7 int add(int a,int b) 8 { 9 return a + b; 10 } 11 }; 12 13 void main() 14 { 15 myclass my1; 16 ... 阅读全文
posted @ 2018-03-16 18:50 喵小喵~ 阅读(184) 评论(0) 推荐(0) 编辑
上一页 1 ··· 25 26 27 28 29 30 31 32 33 ··· 68 下一页