Hi,
If a variable has to be declared before use, then why the following code works? Since in the class definition x is declared after its use in f().
Thanks in advance.Code:#include <iostream>using namespace std; class A { public: int f() { return x; } int x = 10; }; int main() { A a; cout << a.f() << endl; return 0; }