c++ - casting size_t to int to declare size of char array -
I am trying to declare the size of a four array and I need to use the variable value Size_t to declare a shape, can I extract the size_t variable in a shape so that I can do that?
size_t
is an integer type and no one is necessary.
In C ++, if you want the dynamic size array, then you dynamic allocation using new
. That is, you can not use it:
std :: size_t sz = 42; Four carre [sj];
You need to use the following instead:
std :: size_t sz = 42; Char * carray = new char [sz]; // ... and later, when you are done with the array ... Delete [] Cairo;
Or, preferably, you can explicitly delete std :: vector
( std :: vector
) There is no need to remember and you do not have to worry about many proprietary problems that come with manual dynamic allocation):
std :: size_t sz = 42; Std :: vector & lt; Four & gt; Cvector (SZ);
Comments
Post a Comment