I am writing a program for a shopping cart. Everything is derived from the customer. Every customer has a shopping cart. Therefore I thought to put the shopping cart before the Customer class. When doing this I can't declare Shopping cart as a child of Customer. Any fixes?
class ShoppingCart : public Customer
{
private:
Item* cart[MAX_SIZE] = {NULL}; //problem may occur
int size;
public:
void addItem(char* type, char* title, char* description, double price);
void showCart();
};
class Customer
{
private:
int ID, items;
char* firstName, *lastName;
ShoppingCart* Cart;
public:
Customer(char* userFirst, char* userLast, int userID, ShoppingCart* cart)
{
this->ID = userID;
this->firstName = userFirst;
this->lastName = userLast;
this->Cart = cart;
}
friend void ShoppingCart::addItem(char* type, char* title, char* description, double price);
};