c++ size_t to int
To convert a size_t to an int in C++, you can simply cast it using the static_cast operator. Here's an example:
size_t size = 123;
int int_size = static_cast<int>(size);
In this example, we initialize a size_t variable named "size" with a value of 123. We then cast it to an int using static_cast and assign the result to an int variable named "int_size". The resulting int value will be 123, the same as the original size_t value.
原文地址: http://www.cveoy.top/t/topic/ephD 著作权归作者所有。请勿转载和采集!