I'm implementing a binary search tree from "Data Structures & Algorithms in C++". But I don't quite understand their constructor:
Entry(const K& k = K(), const V& v = V())
: _key(k), _value(v) { }
Are _key
and _value
functions? Since they default to functions in the constructor?
This is the class header:
template <typename K, typename V>
class Entry
{
public:
typedef K Key;
typedef V Value;
public:
Entry(const K& k = K(), const V& v = V()) : _key(k), _value(v) { }
const K& key() const { return key; }
const V& value() const { return value; }
void set_key(const K& k) { _key = k; }
void set_value(const V& v) { _value = v; }
private:
K _key;
V _value;
};
Apologies if duplicate, I didn't know what to search for.
Edit: my question is not about the double colon, but the default value _key
and _value
are set to: K& k = K()
and V& v = V()
. Do these imply that the typenames K
and V
are functions?