读书人

考大家个有关问题

发布时间: 2012-05-30 20:20:04 作者: rapoo

考大家个问题
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类嘛!只是不同对象而已

读书人网 >C++

热点推荐