I have these three related class members:
vector<Frame*>* poolFrames;
vector<Frame*>*::iterator frameIterator;
vector<vector<Frame*>::iterator>* poolFrameIterators;
When I compile, gcc tells me
error: invalid use of ‘::’
error: expected ‘;’ before ‘frameIterator’
In reference to the middle line, where I define frameIterators. It goes away when I loose the pointer to the vector and make it a vector::iterator. However, I want them to be pointers. Is there a special way to define the data type that I want, or do I need to use vector::iterator and then dereference?
I see what you were trying to do. You’ve defined
poolFramesas a pointer to a vector. Then you want to defineframeIteratoras an iterator forpoolFrames. SincepoolFramesis a pointer, you think you need a special pointer-to-vector iterator, but you’re mistaken.A vector iterator is a vector iterator is a vector iterator, no matter how you managed to refer to the vector in the first place. You need
frameIteratorto be a simple iterator:To assign a value to that variable, you’ll need to dereference your vector pointer, like this:
If
poolFrameswere a vector instead of a pointer to a vector, you’d use the dot operator instead:poolFrames.begin().