Reputation: 151
This function is giving me errors such as:
error: 'vertice' cannot appear in a constant-expression
error: template argument 1 is invalid
error: `iterator' does not name a type
list< list<vertice> >::iterator extraiLista(string vertice, list< list<vertice> >& listaVertices){
list< list<vertice> >::iterator itVert;
for(itVert = listaVertices.begin(); itVert != listaVertices.end(); itVert++){
list<vertice>::iterator aux = itVert->begin();
if(aux->nome == vertice)
return itVert;
}
return NULL;
}
'vertice' is a struct that I created and I'm having no problems using it in other functions. It's just this one that is giving me trouble. I thought the problem might be with the iterator but I tried it in another function and it worked.
Upvotes: 0
Views: 416
Reputation: 6737
You made at least two errors.
Error 1:
string vertice, list< list<vertice> >
"vertice" cannot be both a typename (as in list<list<vertice> >
) and a variable (as in string vertice
).
Error 2:
return NULL;
Your function returns list<list<iterator> >
. In C++, NULL
is int
. There is no casting from int
to list<list<iterator> >
.
Upvotes: 1
Reputation: 254771
Within the function, vertice
is the name of the function parameter, not the type which it hides.
To refer to the type, you can either elaborate it:
list<class vertice>
or qualify it:
list<::vertice> // assuming it's in the global namespace
but it might be better to choose a different name for the parameter.
Upvotes: 2