When dealing with length, prefer std::size_t
. This is an unsigned integer type that is also the return type of the sizeof
operator. It is not good to use int
because you cannot guarantee that any length will fit. Your code will break if the user constructs an object that is too large. There's also this issue. Accordingly, your loop counter type throughout the class should be std::size_t
.
Jamal
- 34.8k
- 13
- 132
- 237