表达式必须是可修改的左值 Errror
Expression must be a modifiable lvalue Errror
获取表达式一定是一个可修改的左值错误,我看过其他帖子仍然没有意义:/试图制作简单的温度转换器。
1>C:\Users\whatsupnigeh\Desktop\Stuff\asmgodtm\Temperature_Converter\Temperature_Converter\Main.cpp(30,30(:错误 C2106:"=":左操作数必须是 l 值
#include <iostream>
#include <Windows.h>
#include <math.h>
using namespace std;
float final_temp;
int main()
{
SetConsoleTitleA("Temperature Converter");
cout << "{1} Fahrenheit -> Celsius" << endl;
cout << "{2} Celsius -> Fahrenheit" << endl << endl;
cout << "Selection: " << endl;
int choice;
cin >> choice;
if (choice == 1)
{
cout << "Enter F*: " << endl << endl;
float f;
cin >> f;
f - 32 * 5 / 9 = final_temp;
cout << final_temp;
}
if (choice == 2)
{
cout << "Enter C*: " << endl << endl;
float c;
cin >> c;
c * 9 / 5 + 32 = final_temp;
cout << final_temp;
}
else
{
return 0;
}
Sleep(3000);
return 0;
}
正如错误消息所述Expression must be a modifiable lvalue
因此赋值左侧的值必须是变量。
正如S.M.上面所写的,你必须反过来处理你的任务。
f - 32 * 5 / 9 = final_temp;
应该final_temp = ((f - 32) * 5) / 9.;
相关文章:
- 使用C++库在Android项目中修改gradle中的cmake参数,用于插入指令的测试
- 独立读取-修改-写入顺序
- 当系统的卷被修改时,如何修改WASAPI环回捕获卷
- 修改函数中的指针(将另一个指针作为参数传递)
- 为什么我可以通过引用修改常量返回
- 对于结构,表达式必须是可修改的ivalue
- QML:修改在不同QML文件(而非main.QML)中定义的子对象的属性
- 为什么不能修改对象中的值?另外,我如何改进此链表?
- 修改创建帐户程序
- 我应该如何修改此代码以使用给定字符串中的字母打印菱形图案
- 如何从子成员函数修改父公共成员变量
- 修改 VS Code 中的默认C++代码段
- 为什么在我的函数类型后使用引用运算符 (&) 允许我修改它返回的值?
- 如何使用递归打印修改后的星号三角形图案
- 已修改的LinkedList未在文本文件本身中更新
- C++RapidXml-使用first_node()遍历以修改XML文件中节点的值
- 为什么可以修改数组 b?
- 将 C++ 类与 Rcpp 一起使用,从 C 或 R 修改它
- 修改的Fibbonaci C++得到一个大的负数
- 表达式必须是可修改的左值 Errror