+ -
当前位置:首页 → 问答吧 → cin >> p.getx() >> p.gety()为什么不能运行?

cin >> p.getx() >> p.gety()为什么不能运行?

时间:2011-11-28

来源:互联网


首先class point中有这两个fonction
int point::getx() const
{
return this->_x;
}
int point::gety() const
{
return this->_y;
}



在运行cin时有问题出现,不知道有什么问题,
point p
cin >> p.getx() >> p.gety();

错误提示是这样的
Erreur 1 error C2679: '>>' binaire : aucun opérateur trouvé qui accepte un opérande de partie droite de type 'int' (ou il n'existe pas de conversion acceptable)

说">>"不能接受type为int的运算符 (或不存在转换的可能)
怎么办?谢谢大家~

作者: fengheooo   发布时间: 2011-11-28

两个函数返回的是右值,是不能被赋值的,
所以也不放在>>操作的。

作者: relaxisland   发布时间: 2011-11-28