Thursday 14 March 2013

Structure error 2


#include<stdio.h>
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.


Blog Author: Vijay Kumar

Go to: Java Aptitude

No comments:

Post a Comment