Constructor help!

struct BinaryNode
{
Comparable element;
BinaryNode *left;
BinaryNode *right;

BinaryNode(const comparable & theElement, BinaryNode *lt, BinaryNode *rt)
: element (theElement), left(lt), right(rt) {}
};


Can anyone tell me what this piece of code is?

i know its a structure and BinaryNode is the constructor. I just don't know what the ':' represents and everything after that
i think i might have posted this thread in the wrong location....
Those are initializer lists.
element(theElement) will set the value of theElement to element
This is an initializer list as Nisheeth mentioned and you should use it to initialize data members of classes/structs instead of being initialized inside the constructor's body {}. This helps avoiding useless default initializations (like strings to "" etc) and assignments that follow (in the constructor's body).
Also note that this list is executed first (before entering the constructor's body that is).
Finally please use [code][/ code] for your code
Topic archived. No new replies allowed.