Put your products in an array or vector, then it's a simple matter to iterate through the array or vector to find the most expensive product.
PLEASE USE CODE TAGS (the <> formatting button) when posting code.
It makes it easier to read your code and also easier to respond to your post. http://www.cplusplus.com/articles/jEywvCM9/
Hint: You can edit your post, highlight your code and press the <> formatting button.
You mean: "Can one make a compound boolean expression?"
Yes, but you don't want to.
1. Lets assume that the pro1 is expensive.
2. If pro2 is more expensive, then pro2 is the pricey one.
3. If pro3 is more expensive, then pro3 is the pricey one.
4. If pro4 is more expensive, then pro4 is the pricey one.
5. If pro5 is more expensive, then pro5 is the pricey one.
6. You have the most expensive item.
@moonman239:
You are using uninitialized variable.
1 2 3 4 5 6 7 8
Product mostExpensiveProduct = pro1; // Lets assume that the pro1 is expensive.
if ( mostExpensiveProduct.price < pro2.price ) { // If pro2 is more expensive
mostExpensiveProduct = pro2; // then pro2 is the pricey one
}
...
std::cout << "the name of the most expensive product\n"
std::cout << mostExpensiveProduct.Name << '\n';
Now, lets pretend that your shop has million products in its inventory.
Do you really want to copy-paste-edit an if-clause for each?
What if you get three more products? Will you again edit the code and recompile the program?
No. You want a generic and dynamic program. The std::vector, std::max_element & co helps you do that, so learn to use them