|
-
Sep 23rd, 2002, 07:11 PM
#1
Thread Starter
New Member
simple overload of istream << help
hey guys i need help tonight. Im trying to overload istream<< for the enum Color. The error i get is an "illegal operand" for the input << temp; in the overload. Heres what i have...
#include <iostream>
istream & operator>>(istream& input, Color& hue);
int main(void)
{
cout << "enter in a color: Red, Blue -> ";
Color hue;
cin >> hue;
}
istream & operator>>(istream& input, Color& hue)
{
char temp[4];
input << temp;
if (temp == "Red ")
{
hue = Red;
}
else if (temp == "Blue")
{
hue = Blue;
}
else
cerr << "That is an illegal color";
return input;
}
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|