I’m parsing a file and creating a vector of a vector of Foo objects.
vector< vector<Foo*> > mFooVectors;
I have to allow access with the following getFoos function.
const vector<const Foo*>& getFoos(int index);
So I created a const declaration of my vector:
const vector< const vector<const Foo*> > mConstFooVectors;
Now how do I do mConstFooVectors = mFooVectors so I can return a reference to mConstFooVectors?
vector’s copy constructor should be able to handle it, but you’ll have to do it in the initializer list of your class’s constructor since it’s a const member.Edit: That was wrong… Vector’s copy constructor can’t handle it. See David Rodriguez’ post for an explanation (vector and vector are unrelated types).