I have the following code:
class A
{
private:
int x;
public:
A()
{
x = 90;
}
A(A a1, A a2)
{
a1.x = 10;
a2.x = 20;
}
int getX()
{
return this->x;
}
};
I know that code might be weird but I don't understand why a1
and a2
can access private data member x
?