I am making a Template class and want it to have private iterators on it but there's something I'm missing about syntax and would like guidance for doing this right. I cannot show the entire class as it's proprietary but I can show where I am having issues
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
template <class T>
class MyClass
{
private:
typename map<unsigned, T*>::iterator myIterator;
// I want two instances of the above iterator but it won't let me make them
myIterator _it1;
myIterator _it2;
public:
MyClass();
// lots of other code I can't show
};
I'm getting a missing type specifier error for the _it1, _it2 variables. In fact when I remove them I can use the myIterator like a private instance variable:
myIterator = someMap.begin()
What is the proper syntax for these type of private instance iterators?
Also if someone could provide a brief explanation as to why the following doesn't work either I'd appreciate it:
1 2 3 4 5 6 7 8 9 10 11 12 13
template <class T>
class MyClass
{
private:
map<unsigned, T*>::iterator _it1;
map<unsigned, T*>::iterator _it2;
public:
MyClass();
// lots of other code I can't show
};