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.

有帮助吗?

解决方案

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.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top