Function call after constructor declaration [duplicate]What is this weird colon-member (“ : ”) syntax in the constructor?Calling the base constructor in C#Why can't variables be declared in a switch statement?Virtual member call in a constructorWhat are the rules for calling the superclass constructor?How do I call one constructor from another in Java?Can I call a constructor from another constructor (do constructor chaining) in C++?Do the parentheses after the type name make a difference with new?Meaning of 'const' last in a function declaration of a class?Call one constructor from anotherDifference between Constructor and ngOnInit

English - Acceptable use of parentheses in an author's name

How is this kind of structure made?

changing number of arguments to a function in secondary evaluation

What are the advantages and disadvantages of Wand of Cure Light Wounds and Wand of Infernal Healing compared to each other?

Tikzpicture - finish drawing a curved line for a cake slice

Different inverter (logic gate) symbols

Plausibility of Ice Eaters in the Arctic

Who are these characters/superheroes in the posters from Chris's room in Family Guy?

How does "Te vas a cansar" mean "You're going to get tired"?

What is the maximum number of PC-controlled undead?

Ex-contractor published company source code and secrets online

What is the difference between 型 and 形?

Why did the RAAF procure the F/A-18 despite being purpose-built for carriers?

How can I solve for the intersection points of two ellipses?

In a topological space if there exists a loop that cannot be contracted to a point does there exist a simple loop that cannot be contracted also?

Simple Stop watch which i want to extend

First amendment and employment: Can a police department terminate an officer for speech?

Can a fight scene, component-wise, be too complex and complicated?

Dropdowns & Chevrons for Right to Left languages

What is my malfunctioning AI harvesting from humans?

Blocking people from taking pictures of me with smartphone

I accidentally overwrote a Linux binary file

If "more guns less crime", how do gun advocates explain that the EU has less crime than the US?

Which I-94 date do I believe?



Function call after constructor declaration [duplicate]


What is this weird colon-member (“ : ”) syntax in the constructor?Calling the base constructor in C#Why can't variables be declared in a switch statement?Virtual member call in a constructorWhat are the rules for calling the superclass constructor?How do I call one constructor from another in Java?Can I call a constructor from another constructor (do constructor chaining) in C++?Do the parentheses after the type name make a difference with new?Meaning of 'const' last in a function declaration of a class?Call one constructor from anotherDifference between Constructor and ngOnInit






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;








0
















This question already has an answer here:



  • What is this weird colon-member (“ : ”) syntax in the constructor?

    12 answers



I'm currently reading some C++ code, and can't find an explanation for the following syntax.



The function rng_fn is just a random number generator that I want to seed with the same value every time the constructor is called. What does the rng_fn(nullptr) do after the colon, and does this override what happens inside the constructor?



#include Object.h

Object::Object() : rng_fn(nullptr)

unsigned int seed = 1;
rng_fn(seed);



(I have removed everything from the constructor except for the lines I don't understand.)










share|improve this question














marked as duplicate by StoryTeller c++
Users with the  c++ badge can single-handedly close c++ questions as duplicates and reopen them as needed.

StackExchange.ready(function()
if (StackExchange.options.isMobile) return;

$('.dupe-hammer-message-hover:not(.hover-bound)').each(function()
var $hover = $(this).addClass('hover-bound'),
$msg = $hover.siblings('.dupe-hammer-message');

$hover.hover(
function()
$hover.showInfoMessage('',
messageElement: $msg.clone().show(),
transient: false,
position: my: 'bottom left', at: 'top center', offsetTop: -7 ,
dismissable: false,
relativeToBody: true
);
,
function()
StackExchange.helpers.removeMessages();

);
);
);
Mar 27 at 8:53


This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

























    0
















    This question already has an answer here:



    • What is this weird colon-member (“ : ”) syntax in the constructor?

      12 answers



    I'm currently reading some C++ code, and can't find an explanation for the following syntax.



    The function rng_fn is just a random number generator that I want to seed with the same value every time the constructor is called. What does the rng_fn(nullptr) do after the colon, and does this override what happens inside the constructor?



    #include Object.h

    Object::Object() : rng_fn(nullptr)

    unsigned int seed = 1;
    rng_fn(seed);



    (I have removed everything from the constructor except for the lines I don't understand.)










    share|improve this question














    marked as duplicate by StoryTeller c++
    Users with the  c++ badge can single-handedly close c++ questions as duplicates and reopen them as needed.

    StackExchange.ready(function()
    if (StackExchange.options.isMobile) return;

    $('.dupe-hammer-message-hover:not(.hover-bound)').each(function()
    var $hover = $(this).addClass('hover-bound'),
    $msg = $hover.siblings('.dupe-hammer-message');

    $hover.hover(
    function()
    $hover.showInfoMessage('',
    messageElement: $msg.clone().show(),
    transient: false,
    position: my: 'bottom left', at: 'top center', offsetTop: -7 ,
    dismissable: false,
    relativeToBody: true
    );
    ,
    function()
    StackExchange.helpers.removeMessages();

    );
    );
    );
    Mar 27 at 8:53


    This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.





















      0












      0








      0









      This question already has an answer here:



      • What is this weird colon-member (“ : ”) syntax in the constructor?

        12 answers



      I'm currently reading some C++ code, and can't find an explanation for the following syntax.



      The function rng_fn is just a random number generator that I want to seed with the same value every time the constructor is called. What does the rng_fn(nullptr) do after the colon, and does this override what happens inside the constructor?



      #include Object.h

      Object::Object() : rng_fn(nullptr)

      unsigned int seed = 1;
      rng_fn(seed);



      (I have removed everything from the constructor except for the lines I don't understand.)










      share|improve this question















      This question already has an answer here:



      • What is this weird colon-member (“ : ”) syntax in the constructor?

        12 answers



      I'm currently reading some C++ code, and can't find an explanation for the following syntax.



      The function rng_fn is just a random number generator that I want to seed with the same value every time the constructor is called. What does the rng_fn(nullptr) do after the colon, and does this override what happens inside the constructor?



      #include Object.h

      Object::Object() : rng_fn(nullptr)

      unsigned int seed = 1;
      rng_fn(seed);



      (I have removed everything from the constructor except for the lines I don't understand.)





      This question already has an answer here:



      • What is this weird colon-member (“ : ”) syntax in the constructor?

        12 answers







      c++ constructor






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Mar 27 at 8:37









      OrcaOrca

      1155 bronze badges




      1155 bronze badges





      marked as duplicate by StoryTeller c++
      Users with the  c++ badge can single-handedly close c++ questions as duplicates and reopen them as needed.

      StackExchange.ready(function()
      if (StackExchange.options.isMobile) return;

      $('.dupe-hammer-message-hover:not(.hover-bound)').each(function()
      var $hover = $(this).addClass('hover-bound'),
      $msg = $hover.siblings('.dupe-hammer-message');

      $hover.hover(
      function()
      $hover.showInfoMessage('',
      messageElement: $msg.clone().show(),
      transient: false,
      position: my: 'bottom left', at: 'top center', offsetTop: -7 ,
      dismissable: false,
      relativeToBody: true
      );
      ,
      function()
      StackExchange.helpers.removeMessages();

      );
      );
      );
      Mar 27 at 8:53


      This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.











      marked as duplicate by StoryTeller c++
      Users with the  c++ badge can single-handedly close c++ questions as duplicates and reopen them as needed.

      StackExchange.ready(function()
      if (StackExchange.options.isMobile) return;

      $('.dupe-hammer-message-hover:not(.hover-bound)').each(function()
      var $hover = $(this).addClass('hover-bound'),
      $msg = $hover.siblings('.dupe-hammer-message');

      $hover.hover(
      function()
      $hover.showInfoMessage('',
      messageElement: $msg.clone().show(),
      transient: false,
      position: my: 'bottom left', at: 'top center', offsetTop: -7 ,
      dismissable: false,
      relativeToBody: true
      );
      ,
      function()
      StackExchange.helpers.removeMessages();

      );
      );
      );
      Mar 27 at 8:53


      This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.









      marked as duplicate by StoryTeller c++
      Users with the  c++ badge can single-handedly close c++ questions as duplicates and reopen them as needed.

      StackExchange.ready(function()
      if (StackExchange.options.isMobile) return;

      $('.dupe-hammer-message-hover:not(.hover-bound)').each(function()
      var $hover = $(this).addClass('hover-bound'),
      $msg = $hover.siblings('.dupe-hammer-message');

      $hover.hover(
      function()
      $hover.showInfoMessage('',
      messageElement: $msg.clone().show(),
      transient: false,
      position: my: 'bottom left', at: 'top center', offsetTop: -7 ,
      dismissable: false,
      relativeToBody: true
      );
      ,
      function()
      StackExchange.helpers.removeMessages();

      );
      );
      );
      Mar 27 at 8:53


      This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.
























          1 Answer
          1






          active

          oldest

          votes


















          0














          What you are looking at is an initialization list. The members of the class are listed in order of declaration and constructed in place before the body of the constructor is even run.






          share|improve this answer

























          • I see, so any time the random number generated is used after the first two lines of the constructor, it will be seeded by 'seed'?

            – Orca
            Mar 27 at 8:43











          • Well this case is particular. If rng_fn is a function pointer, it will be initialized by a nullptr and then it attempts to dereference the function pointer and pass the seed to it.

            – BugSquasher
            Mar 27 at 14:38














          1 Answer
          1






          active

          oldest

          votes








          1 Answer
          1






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes









          0














          What you are looking at is an initialization list. The members of the class are listed in order of declaration and constructed in place before the body of the constructor is even run.






          share|improve this answer

























          • I see, so any time the random number generated is used after the first two lines of the constructor, it will be seeded by 'seed'?

            – Orca
            Mar 27 at 8:43











          • Well this case is particular. If rng_fn is a function pointer, it will be initialized by a nullptr and then it attempts to dereference the function pointer and pass the seed to it.

            – BugSquasher
            Mar 27 at 14:38















          0














          What you are looking at is an initialization list. The members of the class are listed in order of declaration and constructed in place before the body of the constructor is even run.






          share|improve this answer

























          • I see, so any time the random number generated is used after the first two lines of the constructor, it will be seeded by 'seed'?

            – Orca
            Mar 27 at 8:43











          • Well this case is particular. If rng_fn is a function pointer, it will be initialized by a nullptr and then it attempts to dereference the function pointer and pass the seed to it.

            – BugSquasher
            Mar 27 at 14:38













          0












          0








          0







          What you are looking at is an initialization list. The members of the class are listed in order of declaration and constructed in place before the body of the constructor is even run.






          share|improve this answer













          What you are looking at is an initialization list. The members of the class are listed in order of declaration and constructed in place before the body of the constructor is even run.







          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Mar 27 at 8:39









          BugSquasherBugSquasher

          11010 bronze badges




          11010 bronze badges















          • I see, so any time the random number generated is used after the first two lines of the constructor, it will be seeded by 'seed'?

            – Orca
            Mar 27 at 8:43











          • Well this case is particular. If rng_fn is a function pointer, it will be initialized by a nullptr and then it attempts to dereference the function pointer and pass the seed to it.

            – BugSquasher
            Mar 27 at 14:38

















          • I see, so any time the random number generated is used after the first two lines of the constructor, it will be seeded by 'seed'?

            – Orca
            Mar 27 at 8:43











          • Well this case is particular. If rng_fn is a function pointer, it will be initialized by a nullptr and then it attempts to dereference the function pointer and pass the seed to it.

            – BugSquasher
            Mar 27 at 14:38
















          I see, so any time the random number generated is used after the first two lines of the constructor, it will be seeded by 'seed'?

          – Orca
          Mar 27 at 8:43





          I see, so any time the random number generated is used after the first two lines of the constructor, it will be seeded by 'seed'?

          – Orca
          Mar 27 at 8:43













          Well this case is particular. If rng_fn is a function pointer, it will be initialized by a nullptr and then it attempts to dereference the function pointer and pass the seed to it.

          – BugSquasher
          Mar 27 at 14:38





          Well this case is particular. If rng_fn is a function pointer, it will be initialized by a nullptr and then it attempts to dereference the function pointer and pass the seed to it.

          – BugSquasher
          Mar 27 at 14:38








          Got a question that you can’t ask on public Stack Overflow? Learn more about sharing private information with Stack Overflow for Teams.







          Got a question that you can’t ask on public Stack Overflow? Learn more about sharing private information with Stack Overflow for Teams.





          Popular posts from this blog

          Kamusi Yaliyomo Aina za kamusi | Muundo wa kamusi | Faida za kamusi | Dhima ya picha katika kamusi | Marejeo | Tazama pia | Viungo vya nje | UrambazajiKuhusu kamusiGo-SwahiliWiki-KamusiKamusi ya Kiswahili na Kiingerezakuihariri na kuongeza habari

          Swift 4 - func physicsWorld not invoked on collision? The Next CEO of Stack OverflowHow to call Objective-C code from Swift#ifdef replacement in the Swift language@selector() in Swift?#pragma mark in Swift?Swift for loop: for index, element in array?dispatch_after - GCD in Swift?Swift Beta performance: sorting arraysSplit a String into an array in Swift?The use of Swift 3 @objc inference in Swift 4 mode is deprecated?How to optimize UITableViewCell, because my UITableView lags

          Access current req object everywhere in Node.js ExpressWhy are global variables considered bad practice? (node.js)Using req & res across functionsHow do I get the path to the current script with Node.js?What is Node.js' Connect, Express and “middleware”?Node.js w/ express error handling in callbackHow to access the GET parameters after “?” in Express?Modify Node.js req object parametersAccess “app” variable inside of ExpressJS/ConnectJS middleware?Node.js Express app - request objectAngular Http Module considered middleware?Session variables in ExpressJSAdd properties to the req object in expressjs with Typescript