摘要: 类和对象 引出 设计圆类 #include <cstdio> #include <cstdlib> #include <iostream> using namespace std; const double PI = 3.1415926; // 圆类 // 语法:class 类名(首字母大写) cl 阅读全文
posted @ 2020-11-06 22:22 小宇宙zjy 阅读(110) 评论(0) 推荐(0) 编辑
摘要: 函数 默认参数 #include <cstdlib> #include <cstdio> // 默认参数必须写在最后面,例如:int func(int a,int b = 0, int c = 2) void test(int a, int b = 10) { printf("%d + %d = % 阅读全文
posted @ 2020-11-06 21:33 小宇宙zjy 阅读(48) 评论(0) 推荐(0) 编辑
摘要: 内联函数 宏函数的缺点 缺陷1:要加小括号,保证运算完整 缺陷2:即使加了括号,有时也与预期不符 内联函数 本质也是一个普通函数,在适当时候会替换源码 注意 不能存在循环语句 不能存在过多条件判断语句 函数体不能过于庞大 不能对函数进行取址操作 语法 inline 函数() { // ... } 例 阅读全文
posted @ 2020-11-06 20:58 小宇宙zjy 阅读(46) 评论(0) 推荐(0) 编辑