Consider this code:
class Test
{
public:
Test() { i = 0; }
private:
int i;
};
Data member ‘i’ is used even before it is declared/defined. Should this not be a compilation error ? (It compiled fine!!!)
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
The rule is that member functions defined in the class definition are compiled as if they were defined immediately after the class definition.