Skip to content

Files

Latest commit

 

History

History
13 lines (7 loc) · 619 Bytes

useInitializationList.md

File metadata and controls

13 lines (7 loc) · 619 Bytes

Pattern: Variable is assigned in constructor body

Issue: -

Description

Variable is assigned in constructor body. Consider performing initialization in initialization list.

When an object of a class is created, the constructors of all member variables are called consecutively in the order the variables are declared, even if you don’t explicitly write them to the initialization list. You could avoid assigning variable a value by passing the value to the constructor in the initialization list.

Further Reading