Thursday, September 15, 2005

Anonymous Structures

consider the structure declaration....

struct mark{
int sanskrit;
int tamil;
};

note that no structure of type struct mark has been declared. Only the datatype struct mark is declared.

take a look at the second structure..

struct student_{
int roll;
struct mark;
} george_bush;

This is similar to

struct student_{
int roll;
int sanskrit;
int tamil;
} george_bush;

Inside the structure george_bush, there is another structure which doesnt have a name. Such a structure inside a structure is called an anonymous structure. Same is the explanation for anonymous enums.

The only advantage is see is that, it makes the parent structure more readable.

1 Comments:

Anonymous Anonymous said...

This comment has been removed by a blog administrator.

7:12 AM  

Post a Comment

<< Home