Inline function inside Classes

#include <iostream>
using namespace std;

class A
{
public:
int Getvalue() { return i;}

private:
int i;
};

int main()
{}

The above code compiles properly in g++ or in any other C++ compiler.
BUT, the variable 'i' is used (in 'return i' statement) before it is declared ('int i' declaration comes in private body that is written after the method).
How the compiler resolves a variable usage before declaration?

Class variable scope does not work the same as local scope.

The variable resolves within the scope of the class. That means that all member variables of the class are declared effectively before any execution of method(member function) of that class.

Where in the source file the variable is declared has no bearing as long as it is within the class.