Original Post
Hello everyone,
I have a question about Composition. I want to have a class called Points inside class called Poly. Now at design time I don’t know how many points Poly will have so I want to make a pointer to Points and at the same time pass a constructor. Here is a example:
class Poly
{
public :
Poly(int px, int py, int amount, float 0x,0y) : Points(0x,0y);
private :
Points *ThePoints;
int amount, x, y; //Amount is the amout of
// points poly will have
};
class Points
{
public :
Points(float, float);
~Points();
private :
float x, y;
};
Now my question is, when do I allocate the memory for Points? I would think I allocate it in the constructor of Poly but the constructor for Points would be called before Poly if i'm correct? So how can it be called if there is no memory allocated for it? If someone can help, I thank you a great deal because I can't figure out where to put
ThePoints new Points[amount];
Thanks again
braves
Edited by - braves on 5/2/00 12:36:46 PM