Predict the output or error(s) for the following
#include
main()
{
struct xx
{
int x;
struct yy
{
char s;
struct xx *p;
};
struct yy *q;
};
}
Answer:
Compiler Error
Explanation:
The structure yy is nested within structure xx. Hence, the elements are of yy are to
be accessed through the instance of structure xx, which needs an instance of yy to
be known. If the instance is created after defining the structure the compiler will
not know about the instance relative to xx. Hence for nested structure yy you have
to declare member.
No comments:
Post a Comment