[英]Lvalue required as left operand of asignment error
別人已經回答了這個問題,但是我不知道如何將它應用於我的代碼,因為坦率地說,它太簡單了。
#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;
}
您想設置c
,所以它必須是
c = a+b;
a+b
是一個表達式,而不是您可以分配的變量。
左邊是a+b
,它不是可分配的變量(左值)。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.