What code fragments contain errors (compilation, execution, logical)?
Explanation
(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;

Слідкуй за CodeGalaxy

Мобільний додаток Beta

Get it on Google Play
Зворотній Зв’язок
Cosmo
Зареєструйся Зараз
або Підпишись на майбутні тести