<分区>
int a = a ;
根据赋值运算符的规则,它应该从右到左读取该行。在看到 'a' 未声明的编译器后应该给出编译错误。
但是它给出的是垃圾值
。请澄清。
<分区>
int a = a ;
根据赋值运算符的规则,它应该从右到左读取该行。在看到 'a' 未声明的编译器后应该给出编译错误。
但是它给出的是垃圾值
。请澄清。
最佳答案
§3.3.2/1:
The point of declaration for a name is immediately after its complete declarator (Clause 8) and before its initializer (if any), except as noted below. [ Example:
int x = 12;
{ int x = x; }
Here the second x is initialized with its own (indeterminate) value. —end example ]
关于c++ - 为什么这不会给出编译错误?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17607888/