#include <iostream>using namespace std; int main() { struct A { int x; int y; int z; }; A a{.y = 2, .x = 1}; // error; designator order does not match declaration order A b{.x = 1, .z = 2}; // ok, b.y initialized to 0 return 0;}
Standard input is empty
prog.cpp: In function ‘int main()’: prog.cpp:6:23: error: designator order for field ‘main()::A::x’ does not match declaration order in ‘main()::A’ A a{.y = 2, .x = 1}; // error; designator order does not match declaration order ^
Standard output is empty
The brand new service which powers Ideone!
Widget for compiling and running the source code in a web browser!