2

Following c++ code compiles using g++. I'm a bit curious about how name a is resolve in the constructor

#include <cstdio>

struct A {
  A(int a) : a(a) { };
  const int a;
};

int main() {
  A a(10);
  printf("%d\n", a.a);
  return 0;
}
PeopleMoutainPeopleSea
  • 1,492
  • 1
  • 15
  • 24

0 Answers0