shopping cart

I'm creating a shopping cart program with 2 classes. Class 2 points to class 1. Class 2 contains a function called MyPrice that calculates the total. I'm obviously doing something wrong because I'm getting the following errors. Any help?

In member function 'double ShoppingCart::totalPrice()':
137:28: error: expected primary-expression before '[' token
137:55: error: expected primary-expression before '[' token
140:10: error: cannot convert 'ShoppingCart::totalPrice' from type 'double (ShoppingCart::)()' to type 'double'
141:1: warning: control reaches end of non-void function [-Wreturn-type]

double MyCart::MyPrice()
{
for (int x = 0; x < 100; x++)
{ MyPrice += Thing[x] -> amount() * Thing[x] -> price(); }
return MyPrice;
}
Last edited on
Code tags (the <> button when posting) can improve code readability tremendously. Also, what is your Thing[] variable?
The error message says the error is in ShoppingCart::totalPrice. You've shown us MyCart::MyPrice. It would help if you showed us the function that actually contains the error.
Topic archived. No new replies allowed.