That is not a copy constructor, just a constructor with two parameters... in C++ the syntax:
KEY_VALUE(const KEY &k_,const VALUE &v_) :k(k_), v(v_) {}
is more or less equivalent to
KEY_VALUE(const KEY &k_, const VALUE &v_)
{
k = k_;
v = v_;
}
Note that this is not 100% true as in the second form k
and v
are first initialized by the default constructor and later they are assigned.
Note also that it's also common to name the parameter exactly as the member, thing that makes the syntax even fancier...
KEY_VALUE(const KEY &k,const VALUE &v) :k(k), v(v) {}
If you don't know the initialization list syntax then I assume you never read any decent C++ book. Please do yourself a favor and stop just experimenting C++ with a compiler... C++ cannot be learned that way, it must be studied.
Pick a good book like TCPPPL and read it from cover to cover... even if you are smart there is no way you can learn C++ by experimentation (actually the smarter you are and the harder it will be: in quite a few places C++ is NOT a logical language and there's no way you can guess what a committee decided because of political or historical reasons).