i.e.

class A 
{
   int x = 5;
};

I saw a mailing list post from October 08 where a guy asked if this was going to be added. gcc 4.4 was released April 09, so I would assume it would have been added by then? I haven't tried the svn version, but can anyone comment about if this works for them yet?

Thanks,
Dave

Recommended Answers

All 5 Replies

c++ does not allow initialization of variables like that. No c++ compiler on earth will do it. What you might be referring to is const int x = 5; , which is allowed but not implemented by all compilers.

It's part of the new "c++0x standard" called "delegated constructors".

http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2006/n1986.pdf

I didn't see in that document where int x = 5; would be a legal construct. As far as I can tell that document is talking about class constructors, not variable initialization outside the constructor.

Haha sorry, I totally flaked on that post - I've been looking at both of these feature and I posted the wrong one! I can't find an actual paper on this one, but here is what I saw:
http://www.research.att.com/~bs/C++0xFAQ.html#member-init

On an unrelated note: is there some minimum amount of time that has to pass before thread subscription will "instantly notify" me? For example (and this happens a lot) I posted a question, you answered and I received an email about this answer. Then I replied. Then you replied, and I didn't receive an email - am I misinterpreting the expected behavior?

Thanks,

Dave

On an unrelated note: is there some minimum amount of time that has to pass before thread subscription will "instantly notify" me? For example (and this happens a lot) I posted a question, you answered and I received an email about this answer. Then I replied. Then you replied, and I didn't receive an email - am I misinterpreting the expected behavior?

Thanks,

Dave

I don't know because I don't use that feature. Please post your question in DaniWeb Community Feedback.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.