Expand|Select|Wrap|Line Numbers
- #include <list>
- using namespace std;
- template <typename T>
- list<T>::iterator doStuff( list<T>::iterator myIter ) //--error here
- {
- list<T>::iterator iter = myIter;
- .
- do_some_stuff
- .
- return iter;
- }
- int main() {
- ....
- doStuff(anIterator);
- ...
- }
error: expected constructor, destructor, or type conversion before 'doStuff'
I searched online for some help and I added "typename" before <list T>
at the line labeled "--error here". Then error then became:
template declaration of ‘typename std::list<T, std::allocator<_CharT> >::iterator doStuff’
expected `)' before ‘myIter’
But if I don't use the STL list, i.e., use my own defined class name,
Expand|Select|Wrap|Line Numbers
- template <typename T>
- typename myClass<T>::iterator doStuff(myClass<T>::iterator myIter)
What should I know to define/use template function/class? It looks like the problem lies
somewhere between the standard class and my own class.
What should I do to get the original program working?