In the following code, where a literal is passed to the defined constructor, are there any errors?
struct A {
  int &a;
  A(int &b) : a(b) { }
};

int main() {
  A a(10);
  return 0;
}
Explanation
Yes, because a literal cannot be implicitly converted to a non-constant variable.

Слідкуй за CodeGalaxy

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

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