Groups
Sign in
Groups
comp.lang.c++.moderated
Conversations
About
Send feedback
Help
info
Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss
Learn more
Initialization of data members inside a class
135 views
Skip to first unread message
Joe Bentley
unread,
Feb 21, 2016, 2:30:17 PM
2/21/16
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Sign in to report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to
Is it permissible to initialize non-static data members inside a class,
like so?
class whatever
{
int x = 9;
const int y = 10;
...
};
If so, is there a reference in the "standard" that grants this
permission, and when did this syntax come about?
Thanks
--
[ See
http://www.gotw.ca/resources/clcm.htm
for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]
Norbert_Paul
unread,
Feb 22, 2016, 7:50:15 AM
2/22/16
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Sign in to report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to
Assuming that
http://en.cppreference.com/w/cpp/language/class#Member_specification
is consistent with the standard, I'd say yes.
Norbert
Richard
unread,
Feb 22, 2016, 3:30:17 PM
2/22/16
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Sign in to report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to
[Please do not mail me a copy of your followup]
Joe Bentley <
joe.fo...@googlemail.com
> spake the secret code
<
a8d71d07-329c-41de...@googlegroups.com
> thusly:
>Is it permissible to initialize non-static data members inside a class,
>like so?
>
>class whatever
>{
> int x = 9;
> const int y = 10;
>...
>};
Yes
>If so, is there a reference in the "standard" that grants this
>permission, and when did this syntax come about?
This was introduced in C++11.
See <
http://en.cppreference.com/w/cpp/language/data_members
> for C++11
and C++14 specific discussion on member initialization.
--
"The Direct3D Graphics Pipeline" free book <
http://tinyurl.com/d3d-pipeline
>
The Computer Graphics Museum <
http://computergraphicsmuseum.org
>
The Terminals Wiki <
http://terminals.classiccmp.org
>
Legalize Adulthood! (my blog) <
http://legalizeadulthood.wordpress.com
>
0 new messages