//
#include "pch.h"
#include <iostream>
usingnamespace std;
// Cooking heat can be high or low
enum Heat { low, high };
// Create a struct to simulate order
struct Order {
bool cooked = false;
};
// Subroutine for frying order
void fry(Order order, Heat heat) {
cout << "Frying order at " << heat << " temperature." << endl;
if (heat == low) {
cout << "Frying order at low" << endl;
}
elseif (heat == high) {
cout << "frying order at high" << endl;
}
}
int main()
{
// Create order
Order order = Order();
// Print intro message
cout << "Cooking order:" << endl;
// Fry order
fry(order, low);
fry(order, high);
cout << "Order is ready" << endl;
// End program
system("pause");
return 0;
}
All the program does right now is output a message. order on line 29 is never used by anything in the program. The fry() function outputs a different message based on whether the heat parameter is "high" or "low."
This is a really bad code example to learn from because it's incomplete. It's no wonder you're confused.
Rocketboy wrote:
But why is there an Order and order and Heat and heat
and what is the point of using a subroutine - what is it
I don't know why there is an Order. It does literally nothing in this program. It looks like something the programmer intends to build upon later.
"Order" is a data structure. It's normally used to group different types of data together, but here there's only one piece of data in the struct, so it's pointless. "order" is the name of a variable of type "Order."