上一页 1 ··· 46 47 48 49 50 51 52 53 54 ··· 59 下一页

2016年6月15日

C++ 函数的扩展①

摘要: //函数扩展--内联函数 inline #include using namespace std; /* c++中const常量可以替代宏常数定义 如: const int A = 3; 近似于 #define A 3 但是 const无法替代宏代码片段 c++中推荐使用内联函数替代宏代码片段 c++中使用inline关键字声明内联函数 内联函数声明时inline关键字必须和函数定义结合在... 阅读全文

posted @ 2016-06-15 15:42 寒魔影 阅读(862) 评论(0) 推荐(1) 编辑

C++ const关键字修饰引用

摘要: //const修饰引用的两种用法 #include using namespace std; struct Teacher{ char name[30]; int age; }; void SetA(const Teacher &t1){ //t1.age = 13; //报错 error C3490: 由于正在通过常量对象访问“age”,因此无法对其进行修... 阅读全文

posted @ 2016-06-15 12:11 寒魔影 阅读(328) 评论(0) 推荐(0) 编辑

C++ 指针引用

摘要: //指针引用 #include using namespace std; struct Teacher{ char name[30]; int age; }; int InitA(Teacher **pout/*out*/){ int ERRO_MSG = 0; if (pout==NULL) { ERRO_MSG = 1; ... 阅读全文

posted @ 2016-06-15 10:15 寒魔影 阅读(230) 评论(0) 推荐(0) 编辑

C++ 引用做左值

摘要: //引用做左值 #include<iostream> using namespace std; int SetA(int *p){ *p = 30; return *p; } int& SetB(int *p){ *p = 20; return *p; } void main(){ int a1 = 阅读全文

posted @ 2016-06-15 09:17 寒魔影 阅读(913) 评论(0) 推荐(0) 编辑

2016年6月14日

C++ 引用本质的详解

摘要: //引用本质的理解① #include using namespace std; int GetA(){ int a = 10; return a; } int & GetB(){ int a = 10; printf("a的地址是%x\n", &a); return a; } void main(){ int a1 = 10, a2 = 0... 阅读全文

posted @ 2016-06-14 23:33 寒魔影 阅读(1361) 评论(0) 推荐(0) 编辑

2016年6月13日

C++ 引用基础

摘要: //引用 #include using namespace std; struct Student{ char name[30]; int age; }; struct Teacher{ int &at2; int &bt2; }; int GetNum(Student &s2){ s2.age = 19; return s2.age; ... 阅读全文

posted @ 2016-06-13 23:13 寒魔影 阅读(234) 评论(0) 推荐(0) 编辑

C语言错误 指针的类型错误

摘要: //指针的类型错误 #include #include #include //用const来限制形参的指向不可以修改,优化代码的安全性 int Getnum(int ** const pin/*in*/){ return 1; } //指针的类型 //指针都是有自己的类型的 例如 int *,int ** //指针的类型本质上是对指针所指向的内存空间一种描述 //一级指针,二级指针只... 阅读全文

posted @ 2016-06-13 15:13 寒魔影 阅读(531) 评论(0) 推荐(0) 编辑

2016年6月11日

C++ c++与C语言的区别(三目运算符,const修饰符)

摘要: //区别⑦:三目运算符(C++版本) #include<iostream> using namespace std; //三目运算符 C语言返回变量的值 C++语言是返回变量本身 void main(){ int a = 10; int b = 20; a < b ? a : b = 30; //C 阅读全文

posted @ 2016-06-11 12:57 寒魔影 阅读(672) 评论(0) 推荐(1) 编辑

C++ c++与C语言的区别(struct类型的加强,函数-变量类型加强,bool类型)

摘要: //区别④:struct类型的加强(C++版本) #include using namespace std; //C++中的struct是一个新类型的定义声明 //c++中结构体的默认访问权限public,和类不同 struct Teacher{ //char name[20]="小米";//报错 error C2536: “Teacher::Teacher::name”: 无法指定数... 阅读全文

posted @ 2016-06-11 10:48 寒魔影 阅读(1256) 评论(0) 推荐(0) 编辑

C++ c++与C语言的区别(实用性增强,register关键字增强,全局变量检测增强)

摘要: //区别①:实用性增强 #include<iostream> using namespace std; //C语言中的变量都必须在作用域开始的位置定义!! //C++中更强调语言的“实用性”,所有的变量都可以在需要使用时再定义。 void main(){ int a = 1; printf("ddd 阅读全文

posted @ 2016-06-11 10:09 寒魔影 阅读(529) 评论(0) 推荐(0) 编辑

上一页 1 ··· 46 47 48 49 50 51 52 53 54 ··· 59 下一页

导航