上一页 1 ··· 32 33 34 35 36 37 38 39 40 ··· 68 下一页
摘要: 引用的本质就是两个变量名的地址是同一块内存,可以改变该地址指向的内容 引用指针可以改变指针指向的地址(因为取地址就是指针变量的地址,地址改变,原指针指向的地址也变了),也可以改变指针指向的内容 左值引用与右值引用 1 //左值引用与右值引用 2 void main1() 3 { 4 int a(4) 阅读全文
posted @ 2018-03-11 17:27 喵小喵~ 阅读(107) 评论(0) 推荐(0) 编辑
摘要: 1 #include 2 using namespace std; 3 //改变指针,需要二级指针,也可以用引用 4 5 //左值引用与右值引用 6 void main1() 7 { 8 int a(4); 9 int *p(new int(5)); 10 cout << a << endl; 11 cout << *p << endl; 1... 阅读全文
posted @ 2018-03-11 16:23 喵小喵~ 阅读(119) 评论(0) 推荐(0) 编辑
摘要: 左值引用主要用于引用内存 右值引用主要用于引用寄存器 代码示例 阅读全文
posted @ 2018-03-11 15:46 喵小喵~ 阅读(115) 评论(0) 推荐(0) 编辑
摘要: 1 #include 2 #include 3 using namespace std; 4 5 6 void main() 7 { 8 char ch = 'a'; 9 short sh = 12; 10 int num = 234; 11 double db = 12.324; 12 char *p = "calc"; 13 ... 阅读全文
posted @ 2018-03-11 15:24 喵小喵~ 阅读(125) 评论(0) 推荐(0) 编辑
摘要: #include #include #include using namespace std; //老版本智能指针 void autoptr() { while (1) { double *p( new double[1024 * 1024 * 10] ); auto_ptrautop(p);//接管,自动回收 Sleep(... 阅读全文
posted @ 2018-03-11 15:18 喵小喵~ 阅读(2028) 评论(0) 推荐(0) 编辑
摘要: 1 //模板元实现递归加速,编译的时候慢,代码会增加 2 //把运行的时间节约在编译的时候 3 //递归加速,游戏优化 4 #include 5 using namespace std; 6 7 template 8 struct mydata 9 { 10 enum{res=mydata::res+mydata::res}; 11 }; 12 13 templa... 阅读全文
posted @ 2018-03-11 15:02 喵小喵~ 阅读(115) 评论(0) 推荐(0) 编辑
摘要: 1 #include 2 #include 3 using namespace std; 4 using std::function;//函数包装 5 6 void go() 7 { 8 cout fun1 = go; 19 fun1(); 20 //用lambda表达式包装 21 function fun2 = []() {cout f... 阅读全文
posted @ 2018-03-11 14:48 喵小喵~ 阅读(94) 评论(0) 推荐(0) 编辑
摘要: 1 #include 2 #include 3 using namespace std; 4 5 //解决函数怀孕现象 6 //[](){} 7 //[] =引用,只读 =mutable读原本改副本 &读写原本 //&a,b a可读写,b只能读 8 //() 参数,int a,int b 9 //{}语句 10 void main() 11 { 12 //lamb... 阅读全文
posted @ 2018-03-11 14:43 喵小喵~ 阅读(102) 评论(0) 推荐(0) 编辑
摘要: 1 #include 2 using namespace std; 3 4 5 6 7 8 namespace all 9 { 10 //inline作用为默认调用 11 inline namespace V2017 12 { 13 void fun(int num) 14 { 15 c... 阅读全文
posted @ 2018-03-11 14:04 喵小喵~ 阅读(210) 评论(0) 推荐(0) 编辑
摘要: 1 #include 2 using namespace std; 3 4 //声明返回值为常量表达式 5 constexpr int get() 6 { 7 int num = 5; 8 return num; 9 } 10 11 void main() 12 { 13 int a[5 + get()]; 14 cin.get(); 15... 阅读全文
posted @ 2018-03-11 13:58 喵小喵~ 阅读(93) 评论(0) 推荐(0) 编辑
上一页 1 ··· 32 33 34 35 36 37 38 39 40 ··· 68 下一页