December 1998
Intermediate to advanced
624 pages
13h 8m
English
The constructor turns a pile of incoherent, arbitrary bits into a living object. It initializes the object's internal data members, but it may also allocate resources (memory, files, semaphores, sockets, and so on). The word “ctor” is shorthand for the word “constructor.”
The constructors for class X are member functions named X. Here is an example.

There can be more than one constructor for a class. Each constructor has the same name, so the compiler uses their signatures to uniquely identify them.
A constructor ...
Read now
Unlock full access