A friend convinced me to store a vector of pointers in my class:
vector<Point*> Points;
In my class instead of a vector of "real" objects (what do you call this?). The problem now is that there are several functions (out of my control ie. in a library) that accept a vector<Point>. I've been calling
vector<Point> PointersToReal(vector<Point*> &P)
{
vector<Point> Points;
for(int i = 0; i < P.size(); i++)
{
Points.push_back(*P[i]);
}
return Poitns;
}
Then calling the function, then calling
vector<Point*> PointersToReal(vector<Point> &P)
{
vector<Point*> Points;
for(int i = 0; i < P.size(); i++)
{
Points.push_back(new Point(P[i].x(), P[i].y(), P[i].z()));
}
return Poitns;
}
This just seems like a horrible horrible idea. Is there a standard solution? Or are you not supposed to store pointers if you have to pass real objects?
Thanks,
Dave