<tfoot id='18JPH'></tfoot><legend id='18JPH'><style id='18JPH'><dir id='18JPH'><q id='18JPH'></q></dir></style></legend>

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

      1. <small id='18JPH'></small><noframes id='18JPH'>

        什么是 C++ 中的标量对象?

        时间:2023-08-29

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

        <tfoot id='j4AfO'></tfoot>

              • <legend id='j4AfO'><style id='j4AfO'><dir id='j4AfO'><q id='j4AfO'></q></dir></style></legend>
                  <tbody id='j4AfO'></tbody>
                <i id='j4AfO'><tr id='j4AfO'><dt id='j4AfO'><q id='j4AfO'><span id='j4AfO'><b id='j4AfO'><form id='j4AfO'><ins id='j4AfO'></ins><ul id='j4AfO'></ul><sub id='j4AfO'></sub></form><legend id='j4AfO'></legend><bdo id='j4AfO'><pre id='j4AfO'><center id='j4AfO'></center></pre></bdo></b><th id='j4AfO'></th></span></q></dt></tr></i><div id='j4AfO'><tfoot id='j4AfO'></tfoot><dl id='j4AfO'><fieldset id='j4AfO'></fieldset></dl></div>
                • <bdo id='j4AfO'></bdo><ul id='j4AfO'></ul>
                • 本文介绍了什么是 C++ 中的标量对象?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  据我所知,基本类型是标量,数组是聚合的,但用户定义的类型呢?我会根据什么标准将它们分为两类?

                  As far as I understand it fundamental types are Scalar and Arrays are aggregate but what about user defined types? By what criteria would I divide them into the two categories?

                  struct S { int i; int j };
                  class C { public: S s1_; S s2_ };
                  std::vector<int> V;
                  std::vector<int> *pV = &v;
                  

                  推荐答案

                  简短版本: C++ 中的类型是:

                  Short version: Types in C++ are:

                  • 对象类型:标量、数组、类、联合

                  • Object types: scalars, arrays, classes, unions

                  引用类型

                  函数类型

                  (成员类型)[见下文]

                  (Member types) [see below]

                  void

                  长版

                  • 对象类型

                  • Object types

                  • 标量

                  1. 算术(整数、浮点数)

                  1. arithmetic (integral, float)

                  指针:T * 用于任何类型 T

                  pointers: T * for any type T

                  枚举

                  成员指针

                  nullptr_t

                • 数组:T[]T[N] 用于任何完整的非引用类型 T

                • Arrays: T[] or T[N] for any complete, non-reference type T

                  类:class Foostruct Bar

                  1. 琐碎的课程

                  1. Trivial classes

                  聚合

                  POD 类

                  (等等等等)

                • 联合:联合邮编

                  引用类型:T &T && 用于任何对象或自由函数类型T

                  References types: T &, T && for any object or free-function type T

                  函数类型

                  • 自由函数:R foo(Arg1, Arg2, ...)

                  成员函数:R T::foo(Arg1, Arg2, ...)

                  void

                  成员类型是这样工作的.成员类型的形式为 T::U,但您不能拥有成员类型的对象或变量.您只能拥有成员指针.成员指针具有类型 T::* U,如果 U 是(自由)对象类型,则它是指向成员对象的指针,并且指针-如果 U 是(自由)函数类型,则为成员函数.

                  Member types work like this. A member type is of the form T::U, but you can't have objects or variables of member type. You can only have member pointers. A member pointer has type T::* U, and it is a pointer-to-member-object if U is a (free) object type, and a pointer-to-member-function if U is a (free) function type.

                  所有类型都是完整的,除了 void、未定义大小的数组和声明但未定义的类和联合.除了 void 之外的所有不完整类型都可以完成.

                  All types are complete except void, unsized arrays and declared-but-not-defined classes and unions. All incomplete types except void can be completed.

                  所有类型都可以const/volatile限定.

                  All types can be const/volatile qualified.

                  标头提供了 trait 类来检查这些类型特征中的每一个.

                  The <type_traits> header provides trait classes to check for each of these type characteristics.

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

                • 上一篇:什么是 uint_fast32_t,为什么要使用它而不是常规的 int 和 uint32_t? 下一篇:c++ 枚举的底层类型是什么?

                  相关文章

                • <small id='aepXS'></small><noframes id='aepXS'>

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