2022年1月13日
摘要: 使用 & 为变量和常量作为引用 1 #include <iostream> 2 using namespace std; 3 int main() 4 { 5 int oneInt = 1;//定义一个变量oneInt,并赋值为1 6 int & ref = oneInt;//定义变量ref引用变量 阅读全文
posted @ 2022-01-13 21:26 咫尺流云 阅读(48) 评论(0) 推荐(0) 编辑
  2022年1月12日
摘要: 通过void func 定义函数的默认值和其可以容纳多少个实参 1 #include <iostream> 2 using namespace std; 3 void func(int a = 11, int b = 22, int c = 33) //为函数 func 设置默认值为11,22,33 阅读全文
posted @ 2022-01-12 16:52 咫尺流云 阅读(38) 评论(0) 推荐(0) 编辑
摘要: 首先完整代码如下: #include <iostream> #include <string> using namespace std; int main() { int oneInt1, oneInt2; char strArray[20]; string str; double oneDoubl 阅读全文
posted @ 2022-01-12 16:17 咫尺流云 阅读(186) 评论(0) 推荐(0) 编辑
摘要: const可以把有关的数据定义为常量。 const类型可以修饰:对象,指针,引用 使用const_cast为强制类型转换,将常量强制转换非常量。 1 #include <iostream> 2 using namespace std; 3 int main() 4 { 5 int a = 10; 6 阅读全文
posted @ 2022-01-12 16:16 咫尺流云 阅读(72) 评论(0) 推荐(0) 编辑