Clone Deep copy

I have problem on my assignment, everything seem right, but my polygon don't render as i expected

what i get

https://i.imgur.com/IkhMgkr.png

the result

https://i.imgur.com/rdSeHeH.png


my folder , project file in visual studio 2017
https://drive.google.com/file/d/1lrDre9jn3zmpv3aJhpv7d33M40DT4W2D/view?usp=sharing

Last edited on
This is sort of a guess, but if we look at your Polygon class, you have a dynamically-allocated, non-POD information within Object::PointType * m_pt;

In your Polygon::Clone() method, you have
1
2
3
4
Polygon * Polygon::Clone() const
{
	return new Polygon(*this);
}

This calls the copy constructor for Polygon, but I don't see where you define the copy constructor for Polygon. If you don't define a copy constructor, the compiler will generate one for you, which will just do a shallow copy of your m_pt array instead of a deep copy.

Again, just a guess. But try looking in that direction.
Last edited on
thank that fix my problem as pointer need deep copy
Topic archived. No new replies allowed.