考大家个有关问题

考大家个问题class Student{private:string namepublic:string getname(){return name}bool compare(con

考大家个问题
class Student
{
private:
string name;
public:
string getname(){return name;}
bool compare(const Student& B);
}

bool Student::compare(const Student& B)
{
return this->name>B.name;
}

不许测试,你们觉得,compare里,直接用B.name,也就是该类的私有变量,但是同一个类,可以吗?

[解决办法]
不都是Student类嘛!只是不同对象而已