Browse DevX
Sign up for e-mail newsletters from DevX


Mastering Class Member Initialization

You know initialization is imperative for high-performing applications, but class members refuse to follow the standard rules. By learning the rules—and the exceptions—of initialization, you'll always know what methods to use and when.

n a previous column I explained the rules of POD initialization. The rules of class member initialization are radically different, due to the fact that, in certain contexts, member initialization is mandatory. In addition, class constants have a wide range of initialization forms, depending on their type. The following sections shed some light on the intricate rules of class member initialization and show how to avoid common bugs and inefficiencies.

How do you initialize class members that require explicit initialization? How do you define class constants?

Distinguish between assignment and initialization. Use the appropriate initialization form according to the members type.

Thanks for your registration, follow us on our social networks to keep up-to-date