by scott_s · 15y ago · 0 comments
- A generic type T is introduced into the scope of this member function.
- The template parameter MAXN is a compile time constant that is part of the type of the data structure.
- This is the count member function of the class BST, which is paramaterized on the types mentioned above.
- count does not modify any instance variables of BST.
- The parameter x is passed by constant reference.
- count's return type is int.
- The actual value returned is 1 if find(x) evaluates to true, and 0 if find(x) evaluates to false.
You learn to look for what you need to know when reading the code. Also, it's also worth noting that this code is most decidedly C++ only. C programmers may hate this code.
This really sucks for angle brackets though. Compare
vector<pair<int, string> > blah;
to
vector< pair< int, string > > blah;
vector<pair<int, string>> blah;
And the parser will recognize >> as the end of two template calls, and not the stream operator.