What does :className() mean in a constructor for className?

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP











up vote
11
down vote

favorite
2












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?







share|improve this question






















  • 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














up vote
11
down vote

favorite
2












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?







share|improve this question






















  • 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












up vote
11
down vote

favorite
2









up vote
11
down vote

favorite
2






2





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?







share|improve this question














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?









share|improve this question













share|improve this question




share|improve this question








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
















  • 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












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.






share|improve this answer






















    Your Answer





    StackExchange.ifUsing("editor", function ()
    StackExchange.using("externalEditor", function ()
    StackExchange.using("snippets", function ()
    StackExchange.snippets.init();
    );
    );
    , "code-snippets");

    StackExchange.ready(function()
    var channelOptions =
    tags: "".split(" "),
    id: "1"
    ;
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function()
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled)
    StackExchange.using("snippets", function()
    createEditor();
    );

    else
    createEditor();

    );

    function createEditor()
    StackExchange.prepareEditor(
    heartbeatType: 'answer',
    convertImagesToLinks: true,
    noModals: false,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: 10,
    bindNavPrevention: true,
    postfix: "",
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    );



    );













     

    draft saved


    draft discarded


















    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






























    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.






    share|improve this answer


























      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.






      share|improve this answer
























        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.






        share|improve this answer














        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.







        share|improve this answer














        share|improve this answer



        share|improve this answer








        edited Aug 22 at 18:48

























        answered Aug 22 at 18:38









        R Sahu

        159k1288173




        159k1288173



























             

            draft saved


            draft discarded















































             


            draft saved


            draft discarded














            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













































































            Comments

            Popular posts from this blog

            What does second last employer means? [closed]

            Installing NextGIS Connect into QGIS 3?

            One-line joke