[class.ctor.general] (original) (raw)
11 Classes [class]
11.4 Class members [class.mem]
11.4.5 Constructors [class.ctor]
11.4.5.1 General [class.ctor.general]
Constructors do not have names.
[Example 1: struct S { S(); }; S::S() { } — _end example_]
A constructor is used to initialize objects of its class type.
[Note 1:
Because constructors do not have names, they are never found during unqualified name lookup; however an explicit type conversion using the functional notation ([expr.type.conv]) will cause a constructor to be called to initialize an object.
The syntax looks like an explicit call of the constructor.
— _end note_]
[Example 2: complex zz = complex(1,2.3); cprint( complex(7.8,1.2) ); — _end example_]
[Note 2:
For initialization of objects of class type see [class.init].
— _end note_]
An object created in this way is unnamed.
[Note 4:
Explicit constructor calls do not yield lvalues, see [basic.lval].
— _end note_]
A constructor can be invoked for aconst,volatileorconst volatileobject.
constandvolatilesemantics ([dcl.type.cv]) are not applied on an object under construction.
They come into effect when the constructor for the most derived object ([intro.object]) ends.
The address of a constructor shall not be taken.
[Note 6:
A return statement in the body of a constructor cannot specify a return value ([stmt.return]).
— _end note_]
A constructor shall not be a coroutine.
A constructor shall not have an explicit object parameter ([dcl.fct]).