Constructor parameters


Hello, I'm still trying to completely understand the constructor in this struct. Specifically, what is the purpose of the parameters after the colon?

My guess is that they assign the constructor input parameters (d, prv and nxt)to the struct members data, prev and next.

struct DigitList
{
int data;
DigitList* prev;
DigitList* next;

DigitList (unsigned d, DigitList* prv = 0, DigitList* nxt = 0)
: data(d), prev(prv), next(nxt)
{}
};

Is this correct? Thanks in advance for your help!
They assign those values, or call those functions BEFORE the constructor is run.

It's a common way to init variables to a default value. It's also used to specify which base constructor you wish to call, so you can override the default one and pass a parameter etc.
What the...
Was it not clear enough the first time?
http://www.cplusplus.com/forum/beginner/4124/
Thanks Zaita!

helios - sorry for being a beginner - I am trying to learn!
I'm pointing to the fact that you created duplicate threads. If you had more questions it would have been more appropriate to ask in the original thread (I don't quite see why you said you understood if you still had doubts, but whatever).
helios,

Not only new to C++ but also new to the forum thing. I like the fourm and will get better on postings.

Thanks
Topic archived. No new replies allowed.