M
MJ_India
C++ file with following code compiles without any complaint on GCC and
Microsoft Visual C++.
int main() {
int something = {42}; // 1. LOC that makes me sick
// something = something; // To silent unused variable warning
}
{...} seems perfect for initialization for a structure or an array.
My question is; why is it valid to initialize an int with {42}?
Sometimes I think it is okay, but some other time this is confusing.
Please help.
Microsoft Visual C++ also compiles the following lines without any
complaints:
2. int weird[2] = {{{12}}};
3. int weirder = { { 3,} ,};
Microsoft Visual C++.
int main() {
int something = {42}; // 1. LOC that makes me sick
// something = something; // To silent unused variable warning
}
{...} seems perfect for initialization for a structure or an array.
My question is; why is it valid to initialize an int with {42}?
Sometimes I think it is okay, but some other time this is confusing.
Please help.
Microsoft Visual C++ also compiles the following lines without any
complaints:
2. int weird[2] = {{{12}}};
3. int weirder = { { 3,} ,};