I was writing up my NTree class that I need for a program that I'm working on. My function order() takes in a vector and a string and sorts the vector according to that string so the words closest to the string (one letter off) are at the beginning of the vector. This is the function.
vector <string> order (vector <string> vec, string start)
{ vector <com> set (vec.size());
vector <string> nset (vec.size());
int x, diff;
for (x = 0; x < vec.size(); x++)
{ diff = compare (vec[x], start);
set[x].data = vec[x];
set[x].num = diff; }
sort (set.begin(), set.end(), com_num);
for (x = 0; x < vec.size(); x++)
{ nset[x] = set[x].data; }
return nset;
}
My problem is that it doesn't like the sort call. Now, if I take this function out of my tree and place it with the actual program, it runs fine. The reason it gives is that com_num is an unknown type. This is what it is.
bool com_num (com i, com j) { return (i.num < j.num); }
Am I just missing something? How come it won't work in my tree class, but it will outside of it?