Which of the following structure declarations will throw an error?
Answer: D
Correct answer: struct temp s; struct temp{}; main(){}
This one is an error. Declaring struct temp s; before the structure has been defined means declaring an object of an incomplete type - the compiler does not yet know how much storage to reserve. The other two are fine: the first defines the type and a variable together, and the second defines the type before using it. (A pointer to an incomplete type would be legal, since a pointer’s size is known.)
Please log in or register to report this question.