Suppose I have a class like this:
Code:
class Polygon
{
public:
Polygon(unsigned int, Vertex*, float, float, float);
~Polygon();
void Render();
protected:
Vertex* vertices;
unsigned int VertexCount;
};
In my constructor the second parameter is for an array of a structure called Vertex. Now I got to coding it, and I got to a crossroads. Do I need to call new on vertices, and then set it to equal the parameter, or do I just need to set it to be equal to the parameter. I think that if I just set it to equal the parameter, that when the array I passed to it went out of scope, it won't work right, because vertices won't be pointing to anything; however, I don't know if I dynamically allocate vertices, and then set it to equal the parameter, that it would work right.