(1) - error, because reference a can be initialized only in the initialization list.
(2) - an error because the reference a
refers to the local variable b
passed to the constructor as an argument. When exiting the constructor, the b
variable will be destroyed and the value a becomes undefined
.
(3) - no error. Here the reference a
is equivalent to *this
.
(4) - error. A
is incomplete type
while defining A a
;
Ввійдіть щоб вподобати
Ввійдіть щоб прокоментувати