1

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.

Billal Begueradj
  • 20,717
  • 43
  • 112
  • 130

1 Answers1

1

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());
}
Bo Persson
  • 90,663
  • 31
  • 146
  • 203
  • i did as u said thanks for suggesting now the code is in this manner `void Store:: addMember(Customer* c) { members.push_back(c->name.str()); }` and i am getting an error saying [Error] 'std::string Customer::name' is private – sreeram Sreekrishna Jan 30 '17 at 10:29
  • i got it with a function through which i accessed the variable thankyou @Bo Persson – sreeram Sreekrishna Jan 30 '17 at 10:54