0

I'm studying Data Structure in c++, 2-3 Tree.

And I wnat to know about the ' : MAXKEY(), root()'.

class Two3 {
public:
    Two3(KeyType max, Two3Node<KeyType>* init = 0)
        : MAXKEY(max), root(init) {}; //constructor
    Boolean function(…);
private:
    Two3Node<KeyType>* root;
    KeyType MAXKEY;

Here's that I want to know.

: MAXKEY(max), root(init) {}; //constructor

Rookie
  • 13
  • 1
  • This should be covered in whatever C++ book you're learning from - this is just the normal way for constructors to initialise member variables. – Paul R Oct 15 '15 at 15:38
  • I don't know how to search about this. Please tell me what's the best key for searching this problem... I could not find this when key is, "what is the " : " ???, like this.. – Rookie Oct 15 '15 at 15:50
  • 1
    If you don't already have [a good book on C++](http://stackoverflow.com/questions/388242/the-definitive-c-book-guide-and-list) then you should consider getting one - you can't learn a language form guesswork and Google searches. – Paul R Oct 15 '15 at 15:52

1 Answers1

1

That's an initialization list. It says "initialize MAXKEY with max and initialize root with init". Initializers run before control is passed into constructor body.

sharptooth
  • 167,383
  • 100
  • 513
  • 979