Talk About Network



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++ > default Enum va...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 1 of 8 Topic 45816 of 45898
Post > Topic >>

default Enum values?

by Travis <travis.bowers@[EMAIL PROTECTED] > May 8, 2008 at 03:37 PM

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? Is there
any possibility (perhaps compiler dependent) that if I created and
destroyed Foo objects at an interval of less than 1 second, could
value of week change?

So for talking purposes say I have...

int main()
{
   for (int i = 0; i < 10000; ++i) {
       Foo *f = new Foo;
       cout << f->week << endl;
       delete f;
   }

Will I get 10000 lines of 0?




 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 Tue May 13 14:45:47 CDT 2008.