Here is my own Point class (Point.h
):
class Point {
public:
Point(double x, double y, double z);
Point(const Point& orig);
virtual ~Point();
double getX();
double getY();
double getZ();
void writeOut();
private:
double x, y, z;
};
Here I create a point and add it to the vector<Point>
(main.cpp
):
Point* p = new Point(0.1,0.2,0.3);
vector<Point>* points = new vector<Point>;
points->push_back(*p);
//doing stuff
delete points;
My question: is vector making a copy of the Point and store it (so I need to delete p;
too), or is it storing the one instance created before?
UPDATE:
I read here that push_back "Adds a new element at the end of the vector, after its current last element. The content of val is copied (or moved) to the new element." But which one? Copied or moved? How is it determined?