how to write method definition for the Product* getProductFromID(std::string);

87 Views Asked by At

Please tell me how to write definitions for the functions:

Product* getProductFromID(std::string);

void Store:: addMember(Customer* c)

addmember shud add the member details to the vector named cart and i have tried something like this

void Store:: addMember(Customer* c)
{
    Customer c(std::string n, std::string a, bool pm);
    members.push_back(n.str());
}

I get an error saying [Error] 'n' was not declared in this scope.

1

There are 1 best solutions below

2
Bo Persson On BEST ANSWER

This line

Customer c(std::string n, std::string a, bool pm);

declares a function c that takes three parameters and returns a Customer. Not what you want at all.

Assuming that a Customer contains an n member (which really needs a more descriptive name), the function would just look like

void Store:: addMember(Customer* c)
{
    members.push_back(c->n.str());
}