什么是C ++中的标量对象? [英] What is a scalar Object in C++?
问题描述
据我所知,基本类型是Scalar和Arrays是聚合的,但是用户定义的类型呢?我会以什么标准将它们分为两类?
struct S {int i; int j};
class C {public:S s1_; S s2_};
std :: vector< int> V;
std :: vector< int> * pV =& v;
in C ++ are:
-
对象类型:标量,数组,类和联合
b -
参考类型
-
功能类型
-
)[参见下文]
-
void
长版:
-
对象类型
-
标量
-
算术(积分,浮点)
-
指针:
T *
任何类型T
-
枚举
b -
指向成员
-
nullptr_t
-
-
数组:
T []
或T对于任何完整的非引用类型
T
- 类:
class Foo
或struct Bar
-
小学课程
-
聚集
-
-
(etc。
-
-
-
引用类型:
T&
T&&&&
任何对象或自由功能类型T
-
函数类型
-
自由函数:
R foo(Arg1,Arg2 ,...)
-
成员函数:
RT :: foo(Arg1,Arg2, 。)
-
-
$ c>
成员类型如下所示。成员类型的格式为 T :: U
,但不能有成员类型的对象或变量。您只能有成员指针。成员指针具有类型 T :: * U
,并且它是一个指向成员对象的指针,如果 U
是一个(自由)对象类型,如果 U
是一个(自由)函数类型,则指向成员函数的指针。
所有类型都是完整的,除了 void
,未定义的数组和声明的但未定义的类和联合。除了 void
可以完成所有不完整的类型。
所有类型都可以 const
/
code> header提供了trait类来检查每个类型的特征。
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;
Short version: Types in C++ are:
Object types: scalars, arrays, classes, unions
Reference types
Function types
(Member types) [see below]
void
Long version
Object types
Scalars
arithmetic (integral, float)
pointers:
T *
for any typeT
enum
pointer-to-member
nullptr_t
Arrays:
T[]
orT[N]
for any complete, non-reference typeT
Classes:
class Foo
orstruct Bar
Trivial classes
Aggregates
POD classes
(etc. etc.)
Unions:
union Zip
References types:
T &
,T &&
for any object or free-function typeT
Function types
Free functions:
R foo(Arg1, Arg2, ...)
Member functions:
R T::foo(Arg1, Arg2, ...)
void
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.
All types are complete except void
, unsized arrays and declared-but-not-defined classes and unions. All incomplete types except void
can be completed.
All types can be const
/volatile
qualified.
The <type_traits>
header provides trait classes to check for each of these type characteristics.
这篇关于什么是C ++中的标量对象?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!