Noob Question about classes
Hello -
I have been going through the C++ tutorial about classes. I decided to try a simple program to practice. The program asks the users for a cook time and says if the cooking worked or not depending on if the time entered is positive. I am getting an error that I can't figure out when I try to compile. The error says: expected unqualified-id before '.' token. It occurs on the line:
Code:
cook_successful = microwave.cook_food(cook_time);
Here is the program:
Code:
#include <iostream>
using namespace std;
typedef enum
{
FALSE = 0,
TRUE
} bool_e;
class microwave
{
public:
microwave();
~microwave();
bool_e cook_food (int cook_time);
protected:
int cook_time;
};
microwave::microwave()
{
cook_time = 0;
}
microwave::~microwave()
{
}
bool_e microwave::cook_food (int cook_time)
{
if (cook_time <= 0)
{
return FALSE;
}
else
{
return TRUE;
}
}
int main()
{
int cook_time;
bool_e cook_successful;
cout << "Enter desired cook time: ";
cin >> cook_time;
cin.ignore();
cook_successful = FALSE;
while (!cook_successful)
{
cook_successful = microwave.cook_food(cook_time);
if (cook_successful)
{
cout<< "Enjoy your food!";
}
else
{
cout<< "Cook time must be a positive number. \n Re-enter desired cook time: ";
cin >> cook_time;
cin.ignore();
}
}
cin.get();
}
Thanks in advance!