Dynamic array ? I just get 1 instance.

Hi, i have a problem...

I am trying to create a dynamic array, the problem is, it's not creating an array just 1 instance of the variable type.

Declaration in class.
vertexPosTexNorm *vertices;

vertices = NULL;

The function to create based on a size that is passed into it (Successfully, checking with breakpoints)
void GeometryGenerator::genVertArray(int size)
	vertices = new vertexPosTexNorm[size];

But checking with breakpoints an array is not created, just one instance of vertexPosTexNorm.

Any particular reason this might be happening?

Is size == 1? Otherwise I think you are just misreading the debugging information.
How do you know only one is being created, and how sure are you of the value of size?
Last edited on
Im using breakpoints to check the values of the 'array', and find that only one instance of the type is created. Do dynamic arrays appear differently in the 'autos' window?

Size is 100. Checked again via the auto's window in the debugger. And im sure, the calculation is simply 10*10.

I'm used to seeing arrays in the debugger that are created 'normally', so i can see each element of the array and it's value. Whereas with this array all i see is one set of variables. (ie vertexPosTexNorm has an x,y,z , and that is all im seeing, no reference to elements or anything.
Last edited on
Do dynamic arrays appear differently in the 'autos' window?

This is a feature of your chosen IDE, but as a general rule of thumb, yes. I would not be at all surprised if your IDE's debugger simply interprets vertices as a pointer to a single object (after all, that's what it is).

If you want to be sure, output actual values of the elements in the array. Alternatively, stick some debug in the constructor of the vertexPosTexNorm type (e.g. cout << "I'm bring constructed!" << endl; ) and see if you get a hundred of them.
Last edited on
Thankyou, yes typing the array name followed by a comma and the element i want to see in the watch window displays the values.

ie vertices,1

Topic archived. No new replies allowed.