Hi.

I know that this may be achieved by using STL or MFC, but I have a project for school that must be written without these libraries.

I must create a simple program that deals with graphic objects- points, shapes and 3d figures. A shape object could be deffined by any number of points. So I have a pointer of type
Code:
Point **Elements;
My constructor gets three arguments:
Code:
Shape::Shape(Point& p1, Point& p2, char* _Name)
{
	num=2;
	Elements = new Point*[2];
	Elements[0]=&p1;
	Elements[1]=&p2;
	Name = new char[strlen(_Name)+1];
	strcpy(Name,_Name);
}

Now I have a method which must add a point to the elements of the shape:
Code:
void Shape::AddPoint(Point* p)
{
	Point **tmp_list;
	tmp_list = new Point*[++num];
	int i;
	for(i=0;i<num-1;i++)
		tmp_list[i]=Elements[i];
	delete[] Elements;
	Elements = new Point*[num];
	for(i=0;i<num-1;i++)
		Elements[i]=tmp_list[i];
	Elements[num-1] = new Point(*p);
}
My question is: Is this the proper way of adding a new point pointer to the elements or I just can do this:
Code:
void Shape::AddPoint(Point* p)
{
	Point **tmp_list;
	tmp_list = new Point*[++num];
	int i;
	for(i=0;i<num-1;i++)
		tmp_list[i]=Elements[i];
                tmp_list[num-1]=p;
	delete[] Elements;
                Elements=tmp_list;
}[/
And one more: How do the "delete[] " operator knows how many elements are there in the array?