Initialization order of members in constructor initialization-list

Question | Jul 13, 2016 | nextptr 

In C++, the constructor initialization list is an efficient way to initialize the members during object construction. Here is a simple example of using initialization list in a constructor:

struct A { 
  A(int i) : x(++i), y(++i) {}
  int y;
  int x;
};

Instantiate A and print its member variables:

A a(0);
std::cout << "x=" << a.x << " y=" << a.y;

What do you think are the values of a.x and a.y above?

2015 nextptr