I thought the only way to declare a const<vector>
is:
const std::vector<T> v;
const
applies to the thing to its left, except for when there is nothing on the left then it applies to the thing to its right.
So, const int a=1;
and int const a=1;
are equal.
const int *b
and int const *b
are equal (pointer to a constant int
), but different to int * const b
, which is a constant pointer to a non-constant int
.
This applies to all data types, I choose int
because it is easier to type than std::vector<T>
.
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.