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(){
}
};
Not sure I fully understand what you're asking for, but if I do, I'll try to answer.
Functions func() and func1() are member functions of C, so they have identical access to the exact same names here. Variable B, being a member variable of C, can be referred directly withing func() and func1() without qualifying it with any namespace.
Variable A on the other hand, being a public, non-static member variable of S, requires first instantiating an object of type S before being accessed, like this:
void func()
{
S s;
B = 0; // Directly accessible, member variable of `C`
s.A = B; // A is a non-static member variable of `S`, requires an object
A == 3; // ERROR! A is not a member variable of C
}