I have multiple files for each class. I'm trying to use data from a struct (inside the first class) and use it in the second class.
I've tried putting the struct in its own file, but this felt a bit unnecessary. I've tried a few different ways of coding it out, such as declaring the struct in main and also declaring the struct in the other class.
// class 1
class Shop
{
public:
struct Products
{
int price;
int quantity;
};
void SetProductValue();
private:
float register_total;
};
// class 2:
class Consumer
{
public:
Shop Products;
int total_customers;
bool buy_product(); // <--
for this?
private:
string consumer_name;
float Consumer_balance;
};
What does the function description look like for void buy_product()?
bool Consumer::buy_product();
{
if (consumer_balance < Products.price) return false;
if (consumer_balance >= Products.price) return true;
}
This is one of several ways I've tried, and I get errors for trying to do Products.price