S
stonny
class Number
{
public:
Number(int num=0)
rivate_number(num) {};
void compare(const Number & another_number_class) const
{
if(this->private_number == another_number_class.private_number)
std::cout<<"the two classes have the same numbers !"<<std::endl;
else
std::cout<<"the two classes have different numbers !"<<std::endl;
};
private:
int private_number;
};
In this class Number, the function "compare" can reach the private
data member of both current object and "the parameter object". Is this
because both objects belong to the same class?
stonny
{
public:
Number(int num=0)
void compare(const Number & another_number_class) const
{
if(this->private_number == another_number_class.private_number)
std::cout<<"the two classes have the same numbers !"<<std::endl;
else
std::cout<<"the two classes have different numbers !"<<std::endl;
};
private:
int private_number;
};
In this class Number, the function "compare" can reach the private
data member of both current object and "the parameter object". Is this
because both objects belong to the same class?
stonny