I'm learning about vectors in Accelerated C++
(which is C++ 98, not C++11) by Andrew Koenig and Barbara Moo. In this code...
map<string, vector<int>> xref(istream& in, vector<string> find_words(const string&) = split) { ...
...what is being defined in the block? xref
or find_words
? In my debugger, the call stack goes: main() > xref() > split()
. find_words
isn't defined elsewhere.
// find all the lines that refer to each word in the input
map<string, vector<int> > xref(istream& in, vector<string> find_words(const string&) = split) {
string line;
int line_number = 0;
map<string, vector<int>> ret;
// read the next line
while (getline(in, line)) {
++line_number;
// break the input line into words
vector<string> words = find_words(line);
// remember that each word occurs on the current line
for (vector<string>::const_iterator it = words.begin();
it != words.end(); ++it)
ret[*it].push_back(line_number);
}
return ret;
}
Also, split
looks like this:
vector<string> split(const string& s) { ... }