本文介绍了C ++:变量声明初始化顺序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
当我定义这样的一些变量:
int a = pop(),b = pop c = pop(); C ++保证 a
是
首先要初始化,然后 b
,然后 c
?
$ b $ b
这意味着你的代码被视为:
int a = pop
int b = pop();
int c = pop();
When I'm defining some variables like this:
int a = pop(), b = pop(), c = pop();
does C++ give a guarantee that a
is going to be initialized first, then b
and then c
? or is the order not defined?
解决方案
[dcl.decl]/3 says
Which means your code is treated like:
int a = pop();
int b = pop();
int c = pop();
这篇关于C ++:变量声明初始化顺序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!