简体   繁体   中英

C++: variable declaration initialization order

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

-3- Each init-declarator in a declaration is analyzed separately as if it was in a declaration by itself.

Which means your code is treated like:

int a = pop();
int b = pop();
int c = pop();

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM