|
-
September 25th, 2008, 12:30 AM
#1
Is it possible that enum variables can take a value which is out of set ?
Hi,
Is it valid to assign a value which is out of the set to an ENUM variable ?
for example
-------------
enum status
{
installed = 10;
uninstalled = 20;
repair = 30;
};
enum status current_status;
current_status = 10;
if(current_status == installed)
current_status++;
Can i write a code like this ?, here if the 'if' condition satisfies, the value of current_status will be set to 11 which is out of the set, is it going to be any error in this case.
Thanks
Kiran
-
September 25th, 2008, 12:39 AM
#2
Re: Is it possible that enum variables can take a value which is out of set ?
An enum is just an int with a few compiler restrictions.
The compiler may complain, but if you convince it to do as you say, you won't have any runtime problems resulting.
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
|