My question is about the bold lines... Can a member function called by another object 'see' the private members of the object in the argument?Code:#include<iostream>
using namespace std;
class X
{
private:
int x;
public:
void d(){cout<<x;};
void test(X p)
{
p.x = 10;
this->x = p.x;
};
};
int main()
{
X a,b;
a.test(b);
}
It is compiling in gcc ....but I'd like to know if it is totally 'legal' ?