I get a question.
When does the private or protected member can be accessed?
Thanks.
class a
{
public:
int x;
void set(int Y)
{
y=Y;
}
int f()
{
return y;
}
a()
{
}
a(const a & aa) {
x=aa.x;
y=aa.y;//why the constructor can accessed the private member of aa?
}
private:
int y;
};
When does the private or protected member can be accessed?
Thanks.
class a
{
public:
int x;
void set(int Y)
{
y=Y;
}
int f()
{
return y;
}
a()
{
}
a(const a & aa) {
x=aa.x;
y=aa.y;//why the constructor can accessed the private member of aa?
}
private:
int y;
};
Last edited: