when i compile it say
"store.cpp: In function `void sellProducts(std::vector<Product, std::allocator<Product> >&)':
store.cpp:185: error: expected primary-expression before "int"
store.cpp: In function `void restockProducts(std::vector<Product, std::allocator<Product> >&)':
store.cpp:204: error: expected primary-expression before "int""
void Product::read() {
cout << "Enter the name of the product: ";
cin >> ws;
getline(cin, name);
cout << "Enter the price for a " << name << ": ";
cin >> price;
cout << "Enter the quantity of the " << name << ": ";
cin >> quantity;
}
int choice = 1;
while (choice != 0) {
cout << "\n0. Exit program\n"
<< "1. Report inventory\n"
<< "2. Add a new product\n"
<< "3. Delete a product\n"
<< "4. Sell a product\n"
<< "5. Restock a product\n"
<< "Choice (0-5): ";
cin >> choice;
cin.ignore(1000, '\n');
if (choice == 1) {
listProducts(store);
} else if (choice == 2) {
addProduct(store);
} else if (choice == 3) {
deleteProducts(store);
} else if (choice == 4) {
sellProducts(store);
} else if (choice == 5) {
restockProducts(store);
} else if (choice != 0) {
cout << "\nInvalid choice!\n";
}
}
cout << "\nGoodbye!\n";
return 0;
}
void addProduct(vector<Product>& store) {
cout << "\nAdding a new product:\n";
Product prod;
prod.read();
store.push_back(prod);
}
void listProducts(vector<Product>& store) {
cout << "\nListing products:\n"
<< "# Name: Price: Quantity: Value:\n";
for (unsigned num = 0; num < store.size(); num++) {
cout << (num + 1) << " ";
store[num].print(); // call print() in Product
}
}
void deleteProducts(vector<Product>& store) {
cout << "\nDeleting a product:\n"
<< "# Name: Price: Quantity: Value:\n";
Product prod;
for (unsigned num = 0; num < store.size(); num++) {
cout << (num + 1) << " ";
store[num].print(); // call print() in Product
}
cout << "Enter the number you wish to delete: ";
int pos;
cin >> pos;
for (unsigned i = pos; i < store.size() - 1; i++) {
store[i] = store[i + 1];
}
store.pop_back();
}
void sellProducts(vector<Product>& store){
cout << "\nSelling a product:\n"
<< "# Name: Price: Quantity: Value:\n";
Product prod;
for (unsigned num = 0; num < store.size(); num++) {
cout << (num + 1) << " ";
store[num].print(); // call print() in Product
}
cout << "Enter the product number that you want to sell: ";
int position;
cin >> position;
Product temp = store[position];
cout << "Enter how many of the product you sold: ";
int num1;
cin >> num1;
prod.getQuantity() = num1 - prod.setQuantity(int newQuantity);
store[position] = temp;
}
void restockProducts(vector<Product>& store){
cout << "\nRestocking a product:\n"
<< "# Name: Price: Quantity: Value:\n";
Product prod;
for (unsigned num = 0; num < store.size(); num++) {
cout << (num + 1) << " ";
store[num].print(); // call print() in Product
}
cout << "Enter the product number that you want to restock: ";
int position;
cin >> position;
Product temp = store[position];
cout << "Enter how many of the product you want to add: ";
int num1;
cin >> num1;
prod.getQuantity() = num1 + prod.setQuantity(int newQuantity);
store[position] = temp;
}
*this is line 207*
Be specific for a newbie, Nexius
What is [code] format tag? It's "<>"
Your source is very long so put your code into <> format tag is very necessary if you absolutely want to get some helpful advices and suggestions from others.