Vectors and Pointers ?'s

lets say i have a Vector that holds pointers to a custom class.



then i loop this 10 times to get 10 ?elements? inside the vector
1
2
3
4
5
6
7
std::vector< Ccustom* > vec;
int loopint 0;
while(loopint<10)
{
   vec.push_back(new Ccustom(2+loopint));
   loopint++
}


now say i want to move the first element of Vec to the last. i imagine that to be done like this

1
2
3
4
Ccustom* temp;
temp = vec[0];
vec.erase(vec.begin());
vec.push_back(temp);


is that right? is that the proper usage of pointers and references? i still doubt my skill in pointers.
That looks like it would work.
I guess i should also say . is that the most efficient way?
I'd say nothing wrong with swap? std::swap(v.front(), v.back());
Topic archived. No new replies allowed.