x is A's private member, how come B can refer to it (even it's a const) ?Code:class B{
public:
B(){}
void check(const int& y){cout<<y<<endl;}
};
class A{
int x;
public:
A(){x=1;}
void foo(){B ob; ob.check(x);}
};
int main(){
A oa;
oa.foo();
return 0;
}