Can some one please explain the scope of int A and int B in the void func() and in void func1()?
class C {
struct S {
int A;
};
int B
public :
void func(){
}
void func1(){
}
};
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.
Not sure I fully understand what you’re asking for, but if I do, I’ll try to answer.
Functions
func()andfunc1()are member functions ofC, so they have identical access to the exact same names here. VariableB, being a member variable ofC, can be referred directly withingfunc()andfunc1()without qualifying it with any namespace.Variable
Aon the other hand, being a public, non-static member variable ofS, requires first instantiating an object of typeSbefore being accessed, like this: