I have a simple class that uses an enum for "status". When I use the getStatus
member function, it does indeed return "Busy" but when I print the value, it shows a "1". How can I print "Busy" instead of 1?
http://codepad.org/9NDlxxyU demonstration
#include
using namespace std;
enum Status{Idle, Busy};
class text
{
public:
void SetStatus(Status s);
Status getStatus();
private:
Status s;
};
void text::SetStatus(Status s)
{
this->s = s;
}
Status text::getStatus()
{
return this->s;
}
int main()
{
text myText;
myText.SetStatus(Busy);
cout << myText.getStatus() << endl; //outputs 1, should output "Busy"
}
No comments:
Post a Comment