关于此左值的错误,此左值需要作为赋值的左操作数
Error about this lvalue required as left operand of assignment
这是我的问题!!
for( i = 0; i <= MAX - 2; i++){
for( j = i + 1; j <= MAX - 1; j++){
if(stud[i].getEdad() < stud[j].getEdad()){
temp=stud[i].getEdad();
stud[i].getEdad() = stud[j].getEdad();
stud[j].getEdad() = temp;
}
}
}
我认为问题的根源是
stud[i].getEdad() = stud[j].getEdad().
左值(定位器值)表示在内存中占据某个可识别位置的对象(即具有地址)。右值是通过排除来定义的,即每个表达式要么是左值,要么是右值。因此,从左值的上述定义来看,右值是一个表达式,它不表示对象在内存中占据某个可识别位置
话虽如此,赋值期望左值作为其左操作数,即
//Here foo returns a reference i.e lvalue so ther's no problem in below code.
int& foo()
{
return globalvar;
}
int main()
{
foo() = 10;
return 0;
}
//whereas following one will give you an error since return value is just a temporary object and you are assigning to it.
int foo()
{
return globalvar;
}
int main()
{
foo() = 10;
return 0;
}
相关文章:
- 需要左键作为赋值的左操作数?? 在链表中添加Add_End、删除和Delete_Front?
- 作为赋值(增加引用变量)C++的左操作数所需的左值
- C++ - 左操作数作为赋值的左操作数
- 当我尝试构建此程序时,出现此错误:需要左键作为赋值的左操作数
- 添加数组元素:需要左键作为赋值的左操作数
- 对条件表达式结果的赋值(其中第二个和第三个操作数是相同类型和值类别的变量)是否仍然存在?
- 在 c 程序中需要左操作数作为赋值的左操作数
- 基本类型变量的赋值计算序列,右操作数引发异常
- 需要左值作为赋值错误的左操作数通过 if 语句
- 在 C++ 中需要左键作为赋值错误的左操作数
- 错误:左值需要作为赋值的左操作数
- 强制函数仅作为赋值操作数调用
- Geany c++,错误为“赋值的左操作数需要左值”
- 运算符重载所需的左值作为赋值的左操作数
- 气泡排序中赋值c++的左操作数需要左值
- 错误:使用四进制和随机数生成器进行赋值时,左值需要作为左操作数
- 不能赋值:左键需要作为赋值的左操作数
- 错误:左值需要作为赋值 C++ 的左操作数
- 左值需要作为赋值的左操作数(while 循环)
- 左键需要作为赋值的左操作数?查看其他线程无济于事