Frage

Why is my size changing when assigning a vector to an array?

cout << endl << vertices.size() << endl;  //outputs correct number-> 89473
GLfloat* Vertices = &vertices[0];
GLfloat* Colors = &colors[0];
cout << endl << sizeof(Vertices) << endl; //outputs incorrect number-> 4

I know I can just loop through and assign individually (as opposed to one line of assignment), but I just want to know why this is happening.

War es hilfreich?

Lösung

vertices.size() gives the number of elements in the vertices array (89473) while sizeof(Vertices) calculates the size of a pointer, which happens to be 4.

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top