Struct confusion

closed account (zybCM4Gy)
I'm having a little bit of confusion understanding structures. So a few questions.

1.

1
2
3
4
5
6
struct name
{
    int a = 0;
    int b = 0;
    int c = 0;
} base10[];


Is this uniform initialization? If so is it possible to declare a struct using other types of initialization? My pathetic attempt yielded a compiler error but I don't necessarily understand why.

The reason I'm asking is because the above code looks very similar to say...

 
    int a[4] = {1, 2, 3, 4};
Is this uniform initialization?
No it is a struct with default values assigned to its member.
And base10 would be an array of name's if you provide size of it. It is equivalent ot:
1
2
3
4
5
6
7
struct name
{
    int a = 0;
    int b = 0;
    int c = 0;
};
name base10[...];

The reason I'm asking is because the above code looks very similar to say...
Nope. Curly braces here are not denotes brace-enclosed initializer list here. They are here to show that everyhing inside belongs to name struct. They are like block denoting braces in functions and loops.
closed account (zybCM4Gy)
Ah, that makes more sense, thank you.
Topic archived. No new replies allowed.