Issues with a generic method

Okay, so I've been reading the relevant documentation and I was fairly sure that I was on the right track.

1
2
3
4
5
6
7
8
template <class T>
bool ainlistb(T a, list<T> b) {
    list<T>::iterator it;
    for(it=b.begin();it!=b.end();it++) {
        if(a==*it) return true;
    }
    return false;
}


||In function 'bool ainlistb(T, std::list<T>)':|
|11|error: need 'typename' before 'std::list<T>::iterator' because 'std::list<T>' is a dependent scope|
|11|error: expected ';' before 'it'|
|12|error: 'it' was not declared in this scope|


I don't really get what the error thingy is complaining about, could someone explain it to me :D?

Thanks very much,

code2004
Last edited on
Topic archived. No new replies allowed.