Discussion
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.)
No comment is present. Be the first to comment.
Loading…
Post your comment
Please log in or register to post a comment.
Examination Categories
- SSC Exams
- Banking Exams
- Teaching Exams
- Civil Services Exams
- Railways Exams
- Engineering Recruitment Exams
- Defence Exams
- State Government Exams
- Police Exams
- Insurance Exams
- Nursing Exams
- Other Government Exams
- NRA CET
- PG Entrance Exams
- Campus Placement
- MBA Entrance Exams
- CUET and UG Entrance
- Judiciary Exams
- Regulatory Body Exams
- Software Development