+ 1
Object in structure?
What do this mean? struct something { int a; something b; } ; What will the object of this structure contains?
4 ответов
+ 9
It's always a good idea to tag the language you are asking a question about
+ 7
This structure contains an integer variable, and an instance of itself.
+ 2
The object will not be. This code would not compile for two reasons:
1. There's no "something" defined before the "something" definition is complete. So, even if it were to be forward declared, "something" would've have incomplete type inside the definition. And as the size of it cannot be determined, such structure cannot be defined.
2. Even if this were to be worked around somehow, it would've only led the compiler to the infinite recursion.
The structure may contain a pointer to itself though. And it is used quite often. For linked lists, for example.
+ 2
Part or the section of structure