Last active
August 29, 2015 14:22
-
-
Save nlguillemot/8cee584e7be5da0165ee to your computer and use it in GitHub Desktop.
value initialized member struct
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
using namespace std; | |
struct X | |
{ | |
int a,b,c; | |
}; | |
struct Y | |
{ | |
X x{}; | |
X xs[10]{}; | |
int as[10]{}; | |
}; | |
int main() | |
{ | |
X xs[10]{}; | |
for (X x : xs) | |
{ | |
cout << "{" << x.a << "," << x.b << "," << x.c << "} "; | |
} | |
cout << "\n"; | |
Y y; | |
cout << "{" << y.x.a << "," << y.x.b << "," << y.x.c << "}\n"; | |
for (X x : y.xs) | |
{ | |
cout << "{" << x.a << "," << x.b << "," << x.c << "} "; | |
} | |
cout << "\n"; | |
for (int a : y.as) | |
{ | |
cout << a << " "; | |
} | |
cout << "\n"; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Compiled with /EHsc /nologo /W4 | |
main.cpp | |
Compilation successful! | |
Total compilation time: 109ms | |
{0,0,0} {0,0,0} {0,0,0} {0,0,0} {0,0,0} {0,0,0} {0,0,0} {0,0,0} {0,0,0} {0,0,0} | |
{0,0,0} | |
{49496989,-1238296826,0} {0,0,0} {1919956480,0,0} {0,50987008,0} {-960810910,50789928,49552880} {50987008,0,8} {5,49677504,14} {50789948,49546403,49679328} {50790016,49546421,4} {49487600,-1238296646,50789996} | |
0 0 0 0 0 0 0 0 0 0 | |
Total execution time: 359ms |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment