|
-
Dec 18th, 2001, 02:06 PM
#1
Thread Starter
Addicted Member
Problem comparing two Enum
Hello,
For my program, I created an enum called Month. One the my function requiert a Month arguments and check if it is the current month. Here my function:
PHP Code:
void CAgenda::SetMonth(enum Month NewMonth)
{
Month curMonth = GetCurrentMonth();
if(NewMonth != curMonth)
{
...Some codes
}
else
{
...Some codes
}
}
I get this error on line if(NewMonth != curMonth) :
error C2677: binary '!=' : no global operator defined which takes type 'enum Month' (or there is no acceptable conversion)
How could I compare the two Month?
-
Dec 18th, 2001, 05:59 PM
#2
Frenzied Member
Drop the 'enum' before 'Month'. You don't have to do this in C++, it's something that you used to have to do in old C compilers but isn't necessary any more. The same goes for 'struct'.
Try it like this:
Code:
void CAgenda::SetMonth(Month NewMonth)
{
Month curMonth = GetCurrentMonth();
if(NewMonth != curMonth)
{
...Some codes
}
else
{
...Some codes
}
}
Harry.
"From one thing, know ten thousand things."
-
Dec 18th, 2001, 09:19 PM
#3
Thread Starter
Addicted Member
Oh yeah that worked. I remembered I tried without enum, but it couldn't compile... Thank you for your help.
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
|