What does :className() mean in a constructor for className?
Clash Royale CLAN TAG#URR8PPP
up vote
11
down vote
favorite
I see some code in a codebase I'm working on that looks like:
ZfooName::ZfooName(int magoo)
: ZfooName()
fGoo = magoo;
I'm assuming this is a C++11 feature, since it breaks in VS2012, but what does it mean?
c++ c++11
add a comment |Â
up vote
11
down vote
favorite
I see some code in a codebase I'm working on that looks like:
ZfooName::ZfooName(int magoo)
: ZfooName()
fGoo = magoo;
I'm assuming this is a C++11 feature, since it breaks in VS2012, but what does it mean?
c++ c++11
If ZfooName has a default constructor taking no arguments, this calls it. It is not a C++11 feature. (NVM, it is C++11, I just thought it wasn't).
â jwimberley
Aug 22 at 18:37
1
Possible dupe? stackoverflow.com/questions/26199431/⦠It's not the same question, but the answers contain good info?
â Barry
Aug 22 at 18:41
1
Also good information: stackoverflow.com/questions/308276/â¦
â Tas
Aug 23 at 1:08
add a comment |Â
up vote
11
down vote
favorite
up vote
11
down vote
favorite
I see some code in a codebase I'm working on that looks like:
ZfooName::ZfooName(int magoo)
: ZfooName()
fGoo = magoo;
I'm assuming this is a C++11 feature, since it breaks in VS2012, but what does it mean?
c++ c++11
I see some code in a codebase I'm working on that looks like:
ZfooName::ZfooName(int magoo)
: ZfooName()
fGoo = magoo;
I'm assuming this is a C++11 feature, since it breaks in VS2012, but what does it mean?
c++ c++11
edited Aug 22 at 21:20
asked Aug 22 at 18:35
easythrees
4911725
4911725
If ZfooName has a default constructor taking no arguments, this calls it. It is not a C++11 feature. (NVM, it is C++11, I just thought it wasn't).
â jwimberley
Aug 22 at 18:37
1
Possible dupe? stackoverflow.com/questions/26199431/⦠It's not the same question, but the answers contain good info?
â Barry
Aug 22 at 18:41
1
Also good information: stackoverflow.com/questions/308276/â¦
â Tas
Aug 23 at 1:08
add a comment |Â
If ZfooName has a default constructor taking no arguments, this calls it. It is not a C++11 feature. (NVM, it is C++11, I just thought it wasn't).
â jwimberley
Aug 22 at 18:37
1
Possible dupe? stackoverflow.com/questions/26199431/⦠It's not the same question, but the answers contain good info?
â Barry
Aug 22 at 18:41
1
Also good information: stackoverflow.com/questions/308276/â¦
â Tas
Aug 23 at 1:08
If ZfooName has a default constructor taking no arguments, this calls it. It is not a C++11 feature. (NVM, it is C++11, I just thought it wasn't).
â jwimberley
Aug 22 at 18:37
If ZfooName has a default constructor taking no arguments, this calls it. It is not a C++11 feature. (NVM, it is C++11, I just thought it wasn't).
â jwimberley
Aug 22 at 18:37
1
1
Possible dupe? stackoverflow.com/questions/26199431/⦠It's not the same question, but the answers contain good info?
â Barry
Aug 22 at 18:41
Possible dupe? stackoverflow.com/questions/26199431/⦠It's not the same question, but the answers contain good info?
â Barry
Aug 22 at 18:41
1
1
Also good information: stackoverflow.com/questions/308276/â¦
â Tas
Aug 23 at 1:08
Also good information: stackoverflow.com/questions/308276/â¦
â Tas
Aug 23 at 1:08
add a comment |Â
1 Answer
1
active
oldest
votes
up vote
22
down vote
accepted
This is a new feature in C++11. It's called a delegating constructor.
The constructor calls the default constructor first (the constructor that is being delegated to). After the default constructor returns, the body of the delegating constructor is executed.
See http://www.stroustrup.com/C++11FAQ.html#delegating-ctor and https://en.cppreference.com/w/cpp/language/initializer_list#Delegating_constructor for additional information.
add a comment |Â
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
22
down vote
accepted
This is a new feature in C++11. It's called a delegating constructor.
The constructor calls the default constructor first (the constructor that is being delegated to). After the default constructor returns, the body of the delegating constructor is executed.
See http://www.stroustrup.com/C++11FAQ.html#delegating-ctor and https://en.cppreference.com/w/cpp/language/initializer_list#Delegating_constructor for additional information.
add a comment |Â
up vote
22
down vote
accepted
This is a new feature in C++11. It's called a delegating constructor.
The constructor calls the default constructor first (the constructor that is being delegated to). After the default constructor returns, the body of the delegating constructor is executed.
See http://www.stroustrup.com/C++11FAQ.html#delegating-ctor and https://en.cppreference.com/w/cpp/language/initializer_list#Delegating_constructor for additional information.
add a comment |Â
up vote
22
down vote
accepted
up vote
22
down vote
accepted
This is a new feature in C++11. It's called a delegating constructor.
The constructor calls the default constructor first (the constructor that is being delegated to). After the default constructor returns, the body of the delegating constructor is executed.
See http://www.stroustrup.com/C++11FAQ.html#delegating-ctor and https://en.cppreference.com/w/cpp/language/initializer_list#Delegating_constructor for additional information.
This is a new feature in C++11. It's called a delegating constructor.
The constructor calls the default constructor first (the constructor that is being delegated to). After the default constructor returns, the body of the delegating constructor is executed.
See http://www.stroustrup.com/C++11FAQ.html#delegating-ctor and https://en.cppreference.com/w/cpp/language/initializer_list#Delegating_constructor for additional information.
edited Aug 22 at 18:48
answered Aug 22 at 18:38
R Sahu
159k1288173
159k1288173
add a comment |Â
add a comment |Â
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f51973151%2fwhat-does-classname-mean-in-a-constructor-for-classname%23new-answer', 'question_page');
);
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
If ZfooName has a default constructor taking no arguments, this calls it. It is not a C++11 feature. (NVM, it is C++11, I just thought it wasn't).
â jwimberley
Aug 22 at 18:37
1
Possible dupe? stackoverflow.com/questions/26199431/⦠It's not the same question, but the answers contain good info?
â Barry
Aug 22 at 18:41
1
Also good information: stackoverflow.com/questions/308276/â¦
â Tas
Aug 23 at 1:08