Talk About Network

Google


Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Programming > C++ > Re: default Enu...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 4 of 8 Topic 45816 of 47032
Post > Topic >>

Re: default Enum values?

by Ian Collins <ian-news@[EMAIL PROTECTED] > May 10, 2008 at 08:52 PM

brno wrote:
> Ian Collins dixit:
>> Travis wrote:
>>> I'm curious, if you have an enum say...
>>>
>>> enum Days { Mon, Tue, Wed, Thu, Fri, Sat, Sun };
>>>
>>> I understand the default will be Mon=0, Tue=1, Wed=2, etc.
>>>
>>> What I'm curious about is if there is a Days attribute in a class,
>>> what is the default assuming I don't do anything with it?
>>>
>>> For example
>>>
>>> class Foo
>>> {
>>> public:
>>> Days week;
>>> };
>>>
>>> If I instantiate a Foo object, what is the default of week? 
>>
>> Unless you initialise it, the value is undefined.
>>
> Static ("global") variable are default initialize (int for example is 0)
> Is it undefined even if it is part of a global object ? For example in:
> 
> main.cc:
> --------
> 
> class A {
>     Days d;
> };
> 
> A globalA;
> 
The contents of a will be zero initialised.  OK for Days in this case,
but not a lot of use for

enum Days { Mon = 1, Tue, Wed, Thu, Fri, Sat, Sun };

-- 
Ian Collins.
 




 8 Posts in Topic:
default Enum values?
Travis <travis.bowers@  2008-05-08 15:37:37 
Re: default Enum values?
Ian Collins <ian-news@  2008-05-09 11:12:25 
Re: default Enum values?
brno <brno.barutchek@[  2008-05-10 10:39:30 
Re: default Enum values?
Ian Collins <ian-news@  2008-05-10 20:52:50 
Re: default Enum values?
Travis <travis.bowers@  2008-05-08 16:44:32 
Re: default Enum values?
Ian Collins <ian-news@  2008-05-09 11:58:27 
Re: default Enum values?
Travis <travis.bowers@  2008-05-08 16:53:47 
Re: default Enum values?
Greg Herlihy <greghe@[  2008-05-10 03:00:40 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Fri Jul 25 15:55:35 CDT 2008.