1. 函数返回
int stonetolb(int sts) {
int pounds = 14 * sts;
return (pounds);
}
// 下面直接返回表达式可以避免创建新变量,
// 结果赋给该变量,然后将它返回,效率更高
int stonetolb(int sts) {
return (14 * sts);
}
2. 赋值
int a = 10;
等价
int a(10);
3. 宏定义问题
c++ 中一般使用const 定义来替代 #define 定义,更好!
原因:
1. const能明确指定类型
2. 可以使用c++作用域规则使其限定在特定的函数或文件中
3. 可以用于更复杂的类型