1
嗨,大家好,我需要一些幫助修復基本的c++程序。我在我的SurfaceArea
和我的LateralArea
上收到錯誤。的錯誤是下面....需要一些修復SurfaceArea和LateralArea
稱爲對象類型「INT」不是一個函數或函數指針
無效的操作數的二進制表達(「雙」和「雙」)
我的代碼如下....
#include <iostream>
using namespace std; //allows me to use cout and cin w/o typing std in the main
int main(int argc, const char * argv[])
{
double height; //initialzing my variables
double bottombase;
double topbase;
double volume;
double LateralArea;
double SurfaceArea;
cout << "Please type in the height: "; //asking users for information in order to find volume, and surface area
cin >> height;
cout << "Please type in the length of one side of the bottom base: ";
cin >> bottombase;
cout << "Please type in the length of one side of the top base: ";
cin >> topbase;
volume = height * bottombase * topbase;
cout << "Your volume is: " << volume << endl;
LateralArea = 2(bottombase + topbase) * sqrt(((bottombase-topbase)/2)^2 + height^2);
SurfaceArea = LateralArea1 + bottombase^2 + topbase^2;
cout << "Your surface area is: " << SurfaceArea << endl;
return 0;
}
'2(bottombase + topbase)'應該是'2 *(bottombase + topbase)'。 '''也是按位排他的。使用'pow'代替或者僅僅使用數字本身 –