Originally Posted by
dwks
...
The inner structure separates its members from the outer structure without creating a structure that you can refer to by name. This is more common with unions than structures. (There are also anonymous unions that have neither a name nor instances, but that's a very special case.)
Yeah and it's boss for representing coordinates!
Code:
struct point
{
// Use a union as hybrid storage
union
{
struct
{
float x, y, z;
};
float p[3];
};
point(float a, float b, float c) : x(a), y(b), z(c) { };
void print(void) const
{
printf("(%.00f, %.00f, %.00f)\n", x, y, z);
};
};