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;
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.)
c++ constructor
marked as duplicate by StoryTeller
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.
add a comment |
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.)
c++ constructor
marked as duplicate by StoryTeller
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.
add a comment |
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.)
c++ constructor
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
c++ constructor
asked Mar 27 at 8:37
OrcaOrca
1155 bronze badges
1155 bronze badges
marked as duplicate by StoryTeller
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
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
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.
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
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.
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 anullptr
and then it attempts to dereference the function pointer and pass the seed to it.
– BugSquasher
Mar 27 at 14:38
add a comment |
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
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.
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 anullptr
and then it attempts to dereference the function pointer and pass the seed to it.
– BugSquasher
Mar 27 at 14:38
add a comment |
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.
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 anullptr
and then it attempts to dereference the function pointer and pass the seed to it.
– BugSquasher
Mar 27 at 14:38
add a comment |
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.
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.
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 anullptr
and then it attempts to dereference the function pointer and pass the seed to it.
– BugSquasher
Mar 27 at 14:38
add a comment |
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 anullptr
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
add a comment |
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.