bsherwood
10-15-2005, 05:19 PM
I'm a novice in C++ with a little more Java experience. I've been trying to teach myself C++ and have hit some bumps.
I have a vector of pointers to objects. Whenever I try to initialize it with a for loop I end up with a vector full of pointers pointing to the same object.
Here is what I have done:
for (i = 0; i < max; i ++){
tmpObject = Object(i);
tmpPoint = &tmbObject;
PointerVector[i] = tmpPoint;
}
I understand why this ends up with a vector full of pointers to Object(max-1). How do I fill it up with a vector full of pointers to different Objects?
Thanks.
I have a vector of pointers to objects. Whenever I try to initialize it with a for loop I end up with a vector full of pointers pointing to the same object.
Here is what I have done:
for (i = 0; i < max; i ++){
tmpObject = Object(i);
tmpPoint = &tmbObject;
PointerVector[i] = tmpPoint;
}
I understand why this ends up with a vector full of pointers to Object(max-1). How do I fill it up with a vector full of pointers to different Objects?
Thanks.