سؤال

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