M
Michael Jasn
I had a question about memory management. Please look at the two
functions below. Can you answer the two questions in the comments
below. Thanks so much.
-Mike
func1(std::vector<Point>& points)
{
points.clear(); // Is this the right way to deallocate
// memory allocated below? If not, how
// do I delete the object allocated below
...
points.push_back(Point(1,2)); //The Point object will on the heap
right?
...
}
func2()
{
vector<Point> points;
while(some condition)
{
..
func1(points);
..
}
}
Point:oint(const float& new_x, const float& new_y)
:x(new_x),
y(new_y)
{}
functions below. Can you answer the two questions in the comments
below. Thanks so much.
-Mike
func1(std::vector<Point>& points)
{
points.clear(); // Is this the right way to deallocate
// memory allocated below? If not, how
// do I delete the object allocated below
...
points.push_back(Point(1,2)); //The Point object will on the heap
right?
...
}
func2()
{
vector<Point> points;
while(some condition)
{
..
func1(points);
..
}
}
Point:oint(const float& new_x, const float& new_y)
:x(new_x),
y(new_y)
{}