October 2004
Intermediate to advanced
240 pages
6h 22m
English
Set once, use everywhere: In constructors, using initialization instead of assignment to set member variables prevents needless run-time work and takes the same amount of typing.
Constructors generate initialization code under the covers. Consider:

In reality, constructor’s code is generated as if you wrote:
A() : s1_(), s2_() { s1_ = "Hello, "; s2_ = "world"; }
That is, the objects not explicitly initialized by you are automatically initialized using their default constructors, and then assigned to using their assignment operators. Most often, the assignment operator ...
Read now
Unlock full access