定义变量的地方!
来源:互联网 发布:mac hosts文件会没有吗 编辑:程序博客网 时间:2024/04/30 10:34
这使得它似乎有点更清楚,价值5是只被分配到变量B。
Because defining multiple variables on a single line AND initializing them is a recipe for mistakes, we recommend that you only define multiple variables on a line if you’re not initializing any of them.
因为定义多个变量在一个单一的线和初始化是一方的错误,我们建议您只定义多个变量对线如果你没有初始化任何人。
Rule: Avoid defining multiple variables on a single line if initializing any of them.
规则:避免定义多个变量在一个单一的线如果初始化任何人。
Where to define variables
定义变量的地方
Older C compilers forced users to define all of the variables in a function at the top of the function:
老年编译器强制用户定义函数中的所有变量的函数的顶部的功能:
1234567891011121314151617int main(){ // all variable up top int x; int y; // then code using namespace std; cout << "Enter a number: "; cin >> x; cout << "Enter another number: "; cin >> y; cout << "The sum is: " << x + y << endl; return 0;}
这种风格现在已经过时。编译器不需要在函数的顶部定义所有变量。适当的+ +的风格是将变量定义为可能的变量,尽可能靠近第一次使用这个变量:
123456789101112131415int main(){ using namespace std; cout << "Enter a number: "; int x; // we need x on the next line, so we'll declare it here, as close to its first use as possible. cin >> x; // first use of x cout << "Enter another number: "; int y; // we don't need y until now, so it gets declared here cin >> y; // first use of y cout << "The sum is: " << x + y << endl; return 0;}
0 0
- 定义变量的地方!
- SublimeCodeIntel 让sublime跳转到变量定义的地方
- ACM易错的地方之变量定义
- 在vim中使用cscope查找调用、定义函数和变量的地方
- 在vim中使用cscope查找调用、定义函数和变量的地方
- 在vim中使用cscope查找调用、定义函数和变量的地方
- 在vim中使用cscope查找调用、定义函数和变量的地方
- 变量的推迟定义
- 延后变量的定义
- 变量定义的注意事项
- 变量的声明定义
- zencart变量的定义
- 关于变量的定义
- 糟糕的变量定义!
- 结构变量的定义
- 关于变量的定义
- sap变量的定义
- 变量的声明,定义
- 长臂挖掘机建模要如何运用MapleSim
- 分组交换
- spring源码分析之spring-jdbc模块详解
- 2种方式实现局部刷新
- HBase-1.2.1和Phoenix-4.7.0分布式安装指南
- 定义变量的地方!
- 高速缓存与主存的三种映射方式
- jquery ui tree
- 在存储过程中访问视图授权
- Leetcode #283 Move Zeroes
- C++ 数字与字符串互转
- apns server 官方文档
- AsyncTask下载
- 【知识】beautifulsoup的使用方法