size_t vs int in C++ and/or C

后端 未结 9 1137
南方客
南方客 2020-12-01 07:51

Why is it that in C++ containers, it returns a size_type rather than an int? If we\'re creating our own structures, should we also be encouraged to

9条回答
  •  生来不讨喜
    2020-12-01 08:03

    ints are not guaranteed to be 4 bytes in the specification, so they are not reliable. Yes, size_type would be preferred over ints

提交回复
热议问题