Having the structure with different members delcarations, select lines containing errors:
struct A {
  int a;
  static int b;
  mutable int c;
  int &d;
  const int e;
  A() : d(b), e(c) { }
};

int A::b;

void test(const A *a) {
  a->a = 1;  // 1
  a->b = 2;  // 2
  a->c = 3;  // 3
  a->d = 4;  // 4
  a->e = 5;  // 5
}
Explanation
Line // 1 contains an error, because A::a is a constant in this context.
Line // 2 does not contain errors, because constancy does not apply to static class members.
Line // 3 does not contain errors, because A::c has a mutable modifier.
Line // 4 does not contain errors, because class member references point to a non-constant region of memory.
Line // 5 contains an error, because A::e is a constant.

Follow CodeGalaxy

Mobile Beta

Get it on Google Play
Send Feedback
Cosmo
Sign Up Now
or Subscribe for future quizzes