简体   繁体   中英

CPP vector - what does it mean?

What does mean this row of code? Allocating of memory for some data?

std::vector<float> points((F - E) / sizeof(float));

Thank you

From std::vector documentation ,

std::vector<float> points(n);

creates a vector of size n whose elements are of type float. That is, n is the size of the vector. So for example

std::vector<float> vec(5); //creates a vector(of size 5) of float

In your case n's value is given by the expression:

(F - E) / sizeof(float)

So the vector point in your case have (F - E) / sizeof(float) number of elements.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM