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.


|