Program Notes
Note that when a constructor has a single argument, you can use the following form when initializing a class object:
// a syntax for initializing a class object when// using a constructor with one argumentStonewt incognito = 275;
This is equivalent to the other two forms shown earlier:
// standard syntax forms for initializing class objectsStonewt incognito(275);Stonewt incognito = Stonewt(275);
However, the last two forms can also be used with constructors that have multiple arguments.
Next, note the following two assignments from Listing 11.18:
incognito = 276.8;taft = 325;
The first of these assignments uses the constructor with a type double
argument to convert 276.8
to a type Stonewt
value. This sets the pounds
member of
Get C++ Primer Plus now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.