gpt4 book ai didi

c++ - C++ 中的标量类型附加

转载 作者:行者123 更新时间:2023-11-30 18:44:31 33 4
gpt4 key购买 nike

在 C 中,标量类型为:

  • floating_point(双 float ,...)
  • 积分(int、char、long、...)
  • 指针
  • 枚举

在 C++ 中,添加的标量类型只是:

  • 积分( bool )
  • nullprt_t
  • 成员指针(成员对象指针和成员函数指针)

C++ 中只添加了三种类型标量?

最佳答案

根据标准的C++标量类型的完整列表(引用最新草案):

[basic.fundamental]

There are five standard signed integer types : “signed char”, “short int”, “int”, “long int”, and “long long int”

For each of the standard signed integer types, there exists a corresponding (but different) standard unsigned integer type

Types bool, char, wchar_­t, char8_­t, char16_­t, char32_­t, and the signed and unsigned integer types are collectively called integral types

There are three floating-point types: float, double, and long double.

Integral and floating-point types are collectively called arithmetic types.

[basic.compound]

pointers to non-static class members, which identify members of a given type within objects of a given class, [dcl.mptr]. Pointers to data members and pointers to member functions are collectively called pointer-to-member types.

The type of a pointer to cv void or a pointer to an object type is called an object pointer type. The type of a pointer that can designate a function is called a function pointer type.

[dcl.enum]

The enumeration type declared with an enum-key of only enum is an unscoped enumeration, and its enumerators are unscoped enumerators. The enum-keys enum class and enum struct are semantically equivalent; an enumeration type declared with one of these is a scoped enumeration, and its enumerators are scoped enumerators.

[basic.types]

Arithmetic types ([basic.fundamental]), enumeration types, pointer types, pointer-to-member types ([basic.compound]), std​::​nullptr_­t, and cv-qualified versions of these types are collectively called scalar types.

在这些类型中,C 缺少作用域枚举、成员指针std::nullptr_tchar8_­t ( char8_­t 也尚未在 C++ 中;它将在即将推出的 C++20 中引入)。

bool ( <stdbool.h> ), wchar_t ( <stddef.h> ), char16_­tchar32_­t ( <uchar.h> ) 类型仅在 C 的某些标准 header 中定义。

关于c++ - C++ 中的标量类型附加,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57808011/

33 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com