Ex - 1: Is the following code legal?
struct a
{
int x;
struct a *b;
}
Ans:
Yes.
Explanation:
*b is a pointer to type struct a and so is legal. The compiler knows, the size of the pointer to a structure even before the size of the structure
is determined(as you know the pointer to any type is of same size). This type of structures is known as ‘self-referencing’ structure.
|