For example:
struct X{
X():a{10} {}
void foo() { a = 10; }
private:
int a;
};
Why does this compile when variable a hasn't been declared yet?
The compiler basically does two passes over the class or structure definition. One for the structure/class to parse and handle declarations of members, then one pass for the inline functions.