int foo = foo的标准引用 [英] Standard reference for int foo = foo

查看:122
本文介绍了int foo = foo的标准引用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

int foo = foo; 编译。
C ++标准的哪一部分允许这个?

int foo = foo; compiles. Which part of the C++ standard allows this?

推荐答案


声明[basic.scope.pdecl]

3.3.1 Point of declaration [basic.scope.pdecl]

名称的声明点紧接在其完整的声明器(第8节)之后,在它的初始化器(如果有) / p>

The point of declaration for a name is immediately after its complete declarator (clause 8) and before its initializer (if any),

如果声明在文件范围内,行为是很好定义的。如果你在函数范围有声明,如果你使用 foo 以后[这将被初始化为一些未指定的值]行为将是未定义的。

The behaviour is well defined if the declaration is at file scope. If you have the declaration at function scope and if you use foo later on [which would be initialized to some unspecified value in that case] the behaviour would be undefined.

这篇关于int foo = foo的标准引用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆