<i id='XLBPZ'><tr id='XLBPZ'><dt id='XLBPZ'><q id='XLBPZ'><span id='XLBPZ'><b id='XLBPZ'><form id='XLBPZ'><ins id='XLBPZ'></ins><ul id='XLBPZ'></ul><sub id='XLBPZ'></sub></form><legend id='XLBPZ'></legend><bdo id='XLBPZ'><pre id='XLBPZ'><center id='XLBPZ'></center></pre></bdo></b><th id='XLBPZ'></th></span></q></dt></tr></i><div id='XLBPZ'><tfoot id='XLBPZ'></tfoot><dl id='XLBPZ'><fieldset id='XLBPZ'></fieldset></dl></div>
  • <tfoot id='XLBPZ'></tfoot>

    1. <legend id='XLBPZ'><style id='XLBPZ'><dir id='XLBPZ'><q id='XLBPZ'></q></dir></style></legend>

      <small id='XLBPZ'></small><noframes id='XLBPZ'>

          <bdo id='XLBPZ'></bdo><ul id='XLBPZ'></ul>

        C++ 中的 size_t 和 int 有什么区别?

        What#39;s the difference between size_t and int in C++?(C++ 中的 size_t 和 int 有什么区别?)
      1. <tfoot id='qJPaD'></tfoot>

        <small id='qJPaD'></small><noframes id='qJPaD'>

        <legend id='qJPaD'><style id='qJPaD'><dir id='qJPaD'><q id='qJPaD'></q></dir></style></legend>
        1. <i id='qJPaD'><tr id='qJPaD'><dt id='qJPaD'><q id='qJPaD'><span id='qJPaD'><b id='qJPaD'><form id='qJPaD'><ins id='qJPaD'></ins><ul id='qJPaD'></ul><sub id='qJPaD'></sub></form><legend id='qJPaD'></legend><bdo id='qJPaD'><pre id='qJPaD'><center id='qJPaD'></center></pre></bdo></b><th id='qJPaD'></th></span></q></dt></tr></i><div id='qJPaD'><tfoot id='qJPaD'></tfoot><dl id='qJPaD'><fieldset id='qJPaD'></fieldset></dl></div>
                  <tbody id='qJPaD'></tbody>

                  <bdo id='qJPaD'></bdo><ul id='qJPaD'></ul>
                  本文介绍了C++ 中的 size_t 和 int 有什么区别?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  在几个 C++ 示例中,我看到使用了 size_t 类型,而我会在其中使用简单的 int.有什么区别,为什么 size_t 应该更好?

                  In several C++ examples I see a use of the type size_t where I would have used a simple int. What's the difference, and why size_t should be better?

                  推荐答案

                  来自 友好的维基百科:

                  stdlib.h 和 stddef.h 头文件定义了一种名为 size_t 的数据类型,用于表示对象的大小.接受大小的库函数期望它们的类型为 size_t,而 sizeof 运算符的计算结果为 size_t.

                  The stdlib.h and stddef.h header files define a datatype called size_t which is used to represent the size of an object. Library functions that take sizes expect them to be of type size_t, and the sizeof operator evaluates to size_t.

                  size_t 的实际类型是平台相关的;一个常见的错误是假设 size_t 与 unsigned int 相同,这可能会导致编程错误,尤其是在 64 位架构变得更加普遍的情况下.

                  The actual type of size_t is platform-dependent; a common mistake is to assume size_t is the same as unsigned int, which can lead to programming errors, particularly as 64-bit architectures become more prevalent.

                  另外,查看 为什么 size_t 很重要

                  这篇关于C++ 中的 size_t 和 int 有什么区别?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                  相关文档推荐

                  Unable to access non-const member functions of objects in C++ std::set(无法访问 C++ std::set 中对象的非常量成员函数)
                  Constructing std::function argument from lambda(从 lambda 构造 std::function 参数)
                  STL BigInt class implementation(STL BigInt 类实现)
                  Sync is unreliable using std::atomic and std::condition_variable(使用 std::atomic 和 std::condition_variable 同步不可靠)
                  Move list element to the end in STL(在 STL 中将列表元素移动到末尾)
                  Why is overloading operatoramp;() prohibited for classes stored in STL containers?(为什么禁止对存储在 STL 容器中的类重载 operatoramp;()?)
                    <bdo id='xXgHP'></bdo><ul id='xXgHP'></ul>
                      <tbody id='xXgHP'></tbody>

                    <small id='xXgHP'></small><noframes id='xXgHP'>

                          <tfoot id='xXgHP'></tfoot>
                        • <i id='xXgHP'><tr id='xXgHP'><dt id='xXgHP'><q id='xXgHP'><span id='xXgHP'><b id='xXgHP'><form id='xXgHP'><ins id='xXgHP'></ins><ul id='xXgHP'></ul><sub id='xXgHP'></sub></form><legend id='xXgHP'></legend><bdo id='xXgHP'><pre id='xXgHP'><center id='xXgHP'></center></pre></bdo></b><th id='xXgHP'></th></span></q></dt></tr></i><div id='xXgHP'><tfoot id='xXgHP'></tfoot><dl id='xXgHP'><fieldset id='xXgHP'></fieldset></dl></div>

                            <legend id='xXgHP'><style id='xXgHP'><dir id='xXgHP'><q id='xXgHP'></q></dir></style></legend>