這篇文章主要介紹了c++報錯:lvalue?required?as?left?operand?of?assignment,出現此錯誤原因,是因為,等號左邊是不可被修改的表達式或常量,而表達式或常量不能作為左值,需要的朋友可以參考下
在編程時出現報錯:文章源自四五設計網-http://www.wasochina.com/39184.html
lvalue required as left operand of assignment文章源自四五設計網-http://www.wasochina.com/39184.html
出現此錯誤原因,是因為,等號左邊是不可被修改的表達式或常量。而表達式或常量不能作為左值。歸根結底類似于文章源自四五設計網-http://www.wasochina.com/39184.html
3=b;文章源自四五設計網-http://www.wasochina.com/39184.html
這種錯誤。
而查看代碼發現,是判斷出了問題文章源自四五設計網-http://www.wasochina.com/39184.html
1 2 3 | if (!strA.compare(strB)&&!strC.compare(strD)&&n1=n2){ ???? ... } |
由于n1==n2
漏寫一個等于號,造成括號內由判斷條件變成了賦值語句:左值=n2。而由!strA.compare(strB)&&!strC.compare(strD)&&n1
組成的是一個布爾值常量。顯然是不能作為左值的。文章源自四五設計網-http://www.wasochina.com/39184.html
到此這篇關于c++報錯:lvalue required as left operand of assignment的文章就介紹到這了文章源自四五設計網-http://www.wasochina.com/39184.html 文章源自四五設計網-http://www.wasochina.com/39184.html


評論