Pregunta

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.

¿Fue útil?

Solución

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.

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top