#include <iostream>
usingnamespace std;
class drink
{
public:
int Caffeine;
int Tast;
};
class Person
{
public:
int Caffeine;
int Thirst = 100;
};
int main()
{
Person Bob;
cout << "My name is Bob" << "\n";
cout << "I want some coffee" << "\n";
cout << "Get my thirst to zero to win" << "\n";
cout << "Watch my caffeine" << "\n";
cout << "If I have to much caffeine, I will die" << "\n";
drink Coffee;
Coffee.Caffeine = 10;
Coffee.Tast = 10;
while (true)
{
char a;
cout << "Enter 'D' to drink: ";
cin >> a;
if (a == "d" | a == "D")
{
Bob.Caffeine += Coffee.Caffeine;
}
}
cout << Bob.Caffeine;
char responce;
cin >> responce;
return 0;
}
There's a whole bunch of output errors. Like I said, I suck at classes.
3 simple errors in your code that I see are:
a) you cannot initialize a data member while declaring it in class unless it is static const data member. You should use constructor for initializng any data member.
b) In line 31 you cannot compare a char to string. Corrected way should be using single quotes instead of double.
c) For comparison, OR operator is || and not single |