Reputation: 55
So I was given a Union like this:
union A
{
struct{
SomeType B;
}b;
struct{
SomeType C;
}c;
}a[2];
What does that a[2] mean?
Upvotes: 0
Views: 95
Reputation: 180595
It is an array named a
of size 2 of the type A
which is a union
. This is the same for all class types.
It would be the same as
union A
{
struct{
SomeType B;
}b;
struct{
SomeType C;
}c;
};
A a[2];
Upvotes: 6
Reputation: 310980
This declaration
union A
{
struct{
SomeType B
}b;
struct{
SomeType C
}c;
}a[2];
in fact is equivalent to the following two declarations
union A
{
struct{
SomeType B
}b;
struct{
SomeType C
}c;
};
A a[2];
That is a
is an array of two elements of type union A
.
Upvotes: 2
Reputation:
The a[2]
is declaring a variable, a
, that is an array of type A
, that has a size of 2
.
Upvotes: 0