May 2012
Intermediate to advanced
679 pages
16h 56m
English
C++ aims at making user-defined types as easy to use as built-in-types. In particular, user-defined types may be declared, and their values initialized, the same way as built in types. Therefore, we can use initializer list for initializing the object.
Consider a class Point defined as shown below.
class Point { public : int x, y }
An object of this class can be initialized as
Point p1 = { 3, 4 };
It is somewhat similar to the initialization of a structure.
However, this technique cannot be used for object belonging to any class. The restrictions on the class are as follows:
Read now
Unlock full access