I have this code for copying a polygon class. The problem I have is that in the end the vertices point to the original polygon class location. Since the copy constructor does not seem to be invoked. Why is that ?
Polygon::Polygon(const Polygon &aPolyToCopy)
{
int i;
vertices = new Vertex[aPolyToCopy.count];
for (i=0;i<aPolyToCopy.count;i++)
{
vertices[i].x = aPolyToCopy.vertices[i].x;
vertices[i].y = aPolyToCopy.vertices[i].y;
}
count = aPolyToCopy.count;
}
In a list template I do this
template <class T, int i>
bool SortedVector<T, i>::add ( const T& v )
{
myClass[myCurrent] = v; //Copy constructor not called ?
myCurrent++;
return true;
}
The template is
template <class T, int i>
class SortedVector
{
public:
int maxSize;
T myClass[i];
int myCurrent;
SortedVector();
~SortedVector();
bool add ( const T& v );
};