Napisałem:
template <class T>
T minVecCol(list<list<T> > lista, short int col) {
T ret = 10e7;
list<T> v;
list<list<T> >::iterator vit; // iterator po wektorach (line 278)
list<T>::iterator cit; // iterator po kolumnach (line 279)
vit = lista.begin();
for (; vit!=lista.end(); vit++) {
v = *vit;
cit = v.begin();
advance(cit, col-1);
if (ret>*cit) ret=*cit;
}
return ret;
}
i przy kompilacji są błędy:
g.cpp: In function 'T minVecCol(std::list<std::list<T, std::allocator<_CharT> >, std::allocator<std::list<T, std::allocator<_CharT> > > >, short int)':
g.cpp:278: error: expected;' before 'vit' g.cpp:279: error: expected
;' before 'cit'
g.cpp:280: error: 'vit' was not declared in this scope
g.cpp:283: error: 'cit' was not declared in this scope
g.cpp: In function 'T minVecCol(std::list<std::list<T, std::allocator<_CharT> >, std::allocator<std::list<T, std::allocator<_CharT> > > >, short int) [with T = double]':
g.cpp:1644: instantiated from here
g.cpp:278: error: dependent-name 'std::list<std::list<T, std::allocator<_CharT> >,std::allocator<std::list<T, std::allocator<_CharT> > > >::iterator' is parsed as a non-type, but instantiation yields a type
g.cpp:278: note: say 'typename std::list<std::list<T, std::allocator<_CharT> >,std::allocator<std::list<T, std::allocator<_CharT> > > >::iterator' if a type is meant
g.cpp:279: error: dependent-name 'std::list<T,std::allocator<_CharT> >::iterator' is parsed as a non-type, but instantiation yields a type
g.cpp:279: note: say 'typename std::list<T,std::allocator<_CharT> >::iterator' if a type is meant
make: *** [g.o] Błąd 1
Co powinienem poprawić? (Pierwszy raz chcę skorzystać z template'ów.) :-|