Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/xcode/7.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C++ 指定错误的左操作数需要左值_C++_Xcode_Macos - Fatal编程技术网

C++ 指定错误的左操作数需要左值

C++ 指定错误的左操作数需要左值,c++,xcode,macos,C++,Xcode,Macos,其他人已经回答了这个问题,但我不知道如何将它应用到我的代码中,因为坦白说,它太简单了 #include <iostream> #include <string> using namespace std; int pythagorean () int a; int b; int c; cout << "A: "; cin >> a; cout << "B; "; cin >

其他人已经回答了这个问题,但我不知道如何将它应用到我的代码中,因为坦白说,它太简单了

#include <iostream>
#include <string>
using namespace std;

int pythagorean () 
    int a;
    int b;
    int c;
    cout << "A: ";
    cin >> a;
    cout << "B; ";
    cin >> b;
    a*=a;
    b*=b;
    a+b=c; //This is where I get the error. Any ideas?
    cout << c;
    return 0;
}
#包括
#包括
使用名称空间std;
int毕达哥拉斯()
INTA;
int b;
INTC;
cout>a;
cout>b;
a*=a;
b*=b;
a+b=c//这就是我得到错误的地方。有什么想法吗?

不能您想设置
c
,所以必须

c = a+b;

a+b
是一个表达式,而不是一个可以指定的变量。

您要设置
c
,因此必须

c = a+b;

a+b
是一个表达式,而不是可以指定的变量。

左侧是
a+b
,它不是可指定变量(左值)。

左侧是
a+b
它不是可指定变量(左值)