void Order::GenerateOrders(Order orders[], int n) {
for (int i = 0; i < n; i++)
{
cout << "\nNhap thong tin hoa don: " << i + 1 << endl;
Order Input(orders[i]);// problem here!
}
}
void Order::GenerateOrders(Order orders[], int n) {
for (int i = 0; i < n; i++)
{
cout << "\nNhap thong tin hoa don: " << i + 1 << endl;
Order Input();
}
}
Is it like this? If that is correct, it should continue doing the other line. But the output is just stop at the line 4 in Order:: GenerateOrders
Here is my product.h
1 2 3 4 5
void Product::Input() {
GetName();// here it said that avoid unnamed objects with custom construction and destruction
GetProductionYear();
GetOriginalPrice();
}
On line 5 in GenerateOrders(...) you create a new object of type Order. You do not call the Input() function.
I would guess you want something like this:
1 2 3 4 5 6 7
void Order::GenerateOrders(Order orders[], int n) {
for (int i = 0; i < n; i++)
{
cout << "\nNhap thong tin hoa don: " << i + 1 << endl;
orders[i].Input();// Now Input() is call for each order
}
}
Is it because the new object of type Order is the array to let the function Input() work in?
Um, what?
In your code on line 5 you created a temporary variable named Input which is unrelated to the member function Input() (which is shadowed). orders[i] is provided to the constructor of that temporary variable Input.