LearnFrenzy
Sign in Take a free test

Constructors and Destructors · Constructors MCQ · Question 4

In which order are members initialized? Answer, explanation & discussion

  • MCQ
  • Medium
  • 0 comments
  • Answer explained
  • Moderated community
Question 4 Back to Exercise

In which order are data members initialized?

  • A In the order written in the initializer list
  • B In the order they are declared in the class Correct
  • C Alphabetically
  • D In reverse declaration order
Correct Answer: Option B

Declaration order always wins; compilers warn (-Wreorder) when the initializer list is written in a different order.

Discussion & Comments 0

Share your method, a shortcut, or ask about a step you didn't follow.

No comments yet. Be the first to share your solution!

Post your comment

Comments appear after a quick review by our team.

Search LearnFrenzy

Esc

Quick links