if (sale->taxStatus[i] = "y") // line 44
产生错误:
y.cpp:44:12: error: request for member taxStatus in sale, which is of non-class type Sale*
我的结构:
struct Sale {
int quantity[MAX_SALES];
float unitPrice[MAX_SALES];
char taxStatus[MAX_SALES]; // MAX_SALES = 10
};
完整的功能:
void total(struct Sale sale[], int sales) {
int i = 0;
float subTotal, hst, total = 0;
for (i = 0; i < sales; i++) {
subTotal = subTotal + (sale->quantity[i] * sale->unitPrice[i]);
if (sale->taxStatus[i] = "y")
{
hst = hst + ((sale->quantity[i] * sale->unitPrice[i]) * 0.13);
}
}
cout << "\n" << "Subtotal : " << subTotal << endl;
cout << "HST (13%) : " << hst;
}