Constructor Initilization list vs Initializing in the Ctor body

What is the difference between initializing in Constructor Initialization list Vs Initializing in the body.

Answer:*

1. "Initializing" in the ctor initalization list is truly initialization, but doing the same in the body of a Ctor is "assignment"
2. The member fields such as const, ref, other objects can only be initialized in a ctor initialization list.
3. More optimal, for example if the "assignment" is done in the ctor body, then the object is already constructed and hence less efficient.
4. Static objects and arrays cannot be initialized in the Ctor Init list.

No comments: