商品类对象应用举例,请指出问题
#include <iostream.h>
#include <iomanip.h>
#include <string.h>
inline void CGoods::RegisterGoods(char{}name,int amount,float price){
strcpy(Name,name);Amount=amount;Price=price;
}
void main(){
CGoods car;
char string[21];
int number;
float pr;cout < < "请输入汽车型号:;
cin.getline(string,20);
cout < < "请依次输入汽车数量与单价: ";
cin> > number> > pr;
car.RegisterGoods(string,number,pr);
car.CountTotal();
string[0]= '\0 ';
car.GetName(string);
cout < <setw(20) < <string < <setw(5) < <car.GetAmount();
cout < <setw(10) < <car.GetPrice() < <setw(20) < <car.GetTotal_value() < <endl;
}
[解决办法]
“inline void CGoods::RegisterGoods(char{}name,int amount,float price){”
中的{}是什么,应该是*.
[解决办法]
RegisterGoods(char{}name,int amount,float price)
正如一楼所说的。是那个花括号的问题
可改为:
RegisterGoods(char []name,int amount,float price)
或
RegisterGoods(char *name,int amount,float price)