gcc 4.4 In-class member initializers (c++0x)

Please support our C++ advertiser: Programming Forums - DaniWeb Sister Site
Thread Solved

Join Date: Feb 2008
Posts: 638
Reputation: daviddoria is a jewel in the rough daviddoria is a jewel in the rough daviddoria is a jewel in the rough 
Solved Threads: 46
daviddoria daviddoria is offline Offline
Practically a Master Poster

gcc 4.4 In-class member initializers (c++0x)

 
0
  #1
Jul 4th, 2009
i.e.
  1. class A
  2. {
  3. int x = 5;
  4. };

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
Reply With Quote Quick reply to this message  
Join Date: Aug 2005
Posts: 15,672
Reputation: Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute 
Solved Threads: 1502
Team Colleague
Featured Poster
Ancient Dragon's Avatar
Ancient Dragon Ancient Dragon is online now Online
Still Learning

Re: gcc 4.4 In-class member initializers (c++0x)

 
0
  #2
Jul 4th, 2009
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.
Reply With Quote Quick reply to this message  
Join Date: Feb 2008
Posts: 638
Reputation: daviddoria is a jewel in the rough daviddoria is a jewel in the rough daviddoria is a jewel in the rough 
Solved Threads: 46
daviddoria daviddoria is offline Offline
Practically a Master Poster

Re: gcc 4.4 In-class member initializers (c++0x)

 
0
  #3
Jul 4th, 2009
It's part of the new "c++0x standard" called "delegated constructors".

http://www.open-std.org/jtc1/sc22/wg...2006/n1986.pdf
Reply With Quote Quick reply to this message  
Join Date: Aug 2005
Posts: 15,672
Reputation: Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute 
Solved Threads: 1502
Team Colleague
Featured Poster
Ancient Dragon's Avatar
Ancient Dragon Ancient Dragon is online now Online
Still Learning

Re: gcc 4.4 In-class member initializers (c++0x)

 
0
  #4
Jul 4th, 2009
Originally Posted by daviddoria View Post
It's part of the new "c++0x standard" called "delegated constructors".

http://www.open-std.org/jtc1/sc22/wg...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.
Reply With Quote Quick reply to this message  
Join Date: Feb 2008
Posts: 638
Reputation: daviddoria is a jewel in the rough daviddoria is a jewel in the rough daviddoria is a jewel in the rough 
Solved Threads: 46
daviddoria daviddoria is offline Offline
Practically a Master Poster

Re: gcc 4.4 In-class member initializers (c++0x)

 
0
  #5
Jul 4th, 2009
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++0...ml#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
Reply With Quote Quick reply to this message  
Join Date: Aug 2005
Posts: 15,672
Reputation: Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute 
Solved Threads: 1502
Team Colleague
Featured Poster
Ancient Dragon's Avatar
Ancient Dragon Ancient Dragon is online now Online
Still Learning

Re: gcc 4.4 In-class member initializers (c++0x)

 
0
  #6
Jul 4th, 2009
Originally Posted by daviddoria View Post
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.
Reply With Quote Quick reply to this message  
Reply

This thread has been marked solved.
Perhaps start a new thread instead?
Message:




Views: 286 | Replies: 5
Thread Tools Search this Thread



Tag cloud for C++
About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC