the first part is I can't get an or condition to work. Suppose I have
and I enter 1, 2, or anything at all, the loop never ends. Yet if i do
the code ends up working. Why is this so?
Secondly, I don't understand while making a struct compiles, but changing it to class does not.
This compiles:
and this
gets the errors
Thanks for any help.
Code:
bool done = false;
int value;
while(!done)
{
cin >> value;
if(value==1 || value==2)
done=true;
}
and I enter 1, 2, or anything at all, the loop never ends. Yet if i do
Code:
if(value>0 || value <3)
Secondly, I don't understand while making a struct compiles, but changing it to class does not.
This compiles:
Code:
#ifndef TEMPCOVERTER_H
#define TEMPCOVERTER_H
struct Temp {
double value;
Temp ();
Temp (double temp);
Temp convert2F();
Temp convert2C();
double print();
};
#endif // TEMPCOVERTER_H
and this
Code:
#ifndef TEMPCOVERTER_H
#define TEMPCOVERTER_H
class Temp {
double value;
Public:
Temp ();
Temp (double temp);
Temp convert2F();
Temp convert2C();
double print();
};
#endif // TEMPCOVERTER_H
gets the errors
Code:
tempCoverter.h:11: error: invalid use of undefined type 'class Temp'
tempCoverter.h:6: error: forward declaration of 'class Temp'
tempCoverter.h:11: error: ISO C++ forbids declaration of 'Public' with no type
tempCoverter.h:6: error: candidates are: Temp::Temp(const Temp&)
tempCoverter.h:12: error: Temp::Temp(double)
Thanks for any help.