基本上,我在c++中设置了我的双打,出于某种原因,它给了我这个错误
"..\project2_name.cpp:56:9:错误:函数‘双重总计(双,双,双)’的赋值。“
double appleprice=0;
double pearprice=0;
double tomatoprice=0;
double completetotal=0;
double total(double appleprice, double pearprice, double tomatoprice)
{
total = appleprice + pearprice + tomatoprice;
return total;
}我有一个开关大小写,它是从一个菜单中调用的,除了总菜单: case '3':cout<< "You a a番茄“<< endl;番茄=productsadd(番茄);price = 3.02;tomatoprice =addprice(价格);cout <<”您已经订购了“<< <<”番茄“番茄”<< endl;<
case '4':
cout<< "Your Full order" << endl;
completetotal = total(appleprice, pearprice, tomatoprice);
cout << "You have on order " << apple << " apples. " << appleprice << " price."<< endl;
cout << "You have on order " << pear << " pears. " << pearprice << " price."<< endl;
cout << "You have on order " << tomato << " tomatos. " << tomatoprice << " price."<< endl;
cout << "You have a total of " << completetotal << endl;
break;发布于 2016-10-16 02:49:03
因为total是函数的名称,所以不能使用它。使用临时变量或可能将代码更改为
double total(double appleprice, double pearprice, double tomatoprice)
{
return appleprice + pearprice + tomatoprice;
}https://stackoverflow.com/questions/40066313
复制相似问题