C++ Member Initializer List

Just to clarify something that came up in some of the other answers… There is no requirement that the initializer list be in either the source (.cpp) or header (.h) file. In fact, the compiler does not distinguish between the two types of files. The important distinction is between the contructor’s declaration and it’s definition. … Read more

How do C++ class members get initialized if I don’t do it explicitly?

In lieu of explicit initialization, initialization of members in classes works identically to initialization of local variables in functions. For objects, their default constructor is called. For example, for std::string, the default constructor sets it to an empty string. If the object’s class does not have a default constructor, it will be a compile error … Read more

tech