I would like to make a function that manipulates a vector to select it, and return it. (It would be best to return an iterator that points to this choice.)
Ok, I have this code here in my header:
class Ecran {
template<typename T>
static T* SelectFrom(vector<T> & v);
}
Implementation:
template <class T>
T* Ecran::SelectFrom(vector<T> &v){
int max = v.size();
cout << "Veuillez selectionner un objet parmis les suivants:" << endl << endl;
cout << "0) Aucun" << endl;
for (int i = 1; i <= max; i++){
cout << i << ") " << v[i-1] << endl;
}
bool isValid = false;
string raw;
int input;
while (!isValid){
raw = GetWord();
input = atoi(raw.c_str());
if( (input >= 0) && (input <= max)){
isValid = true;
}
}
if (input == 0){
return 0;
}
return & (v[input -1]);
}
So here is the problem: when I use it, the compiler tells me that:
undefined link to `Club * Ecran :: SelectFrom (std :: vector> &)
I use it like this:
Club * toDel = Ecran::SelectFrom(_clubs);
To this, any help would be greatly appreciated. Also, there would be a way to do this, but return an iterator instead of a point in T?
Thanks already.
source
share