-1

In C the scalar type are:

  • floating_point (double float, ...)
  • integral (int, char, long, ...)
  • pointer
  • enum

In C++ the scalar type added are just :

  • integral (bool)
  • nullprt_t
  • member pointer (member object pointer and member function pointer)

There is just the three type scalar added to C++?

Vlad from Moscow
  • 301,070
  • 26
  • 186
  • 335
Ben
  • 131
  • 1
  • 1
  • 7

2 Answers2

3

The complete list of scalar types in C++ according to the standard (quoting the latest draft):

[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.

Of these types, C lacks scoped enumerations, pointers-to-member, std::nullptr_t and char8_­t (char8_­t is not yet in C++ either; it will be introduced in the upcoming C++20).

bool (<stdbool.h>), wchar_t (<stddef.h>), char16_­t and char32_­t (<uchar.h>) types are only defined in certain standard headers in C.

eerorika
  • 232,697
  • 12
  • 197
  • 326
1

In C++ the scalar types are (6.7 Types)

9 Arithmetic types (6.7.1), enumeration types, pointer types, pointer-to-member types (6.7.2), std::nullptr_t, and cv-qualified (6.7.3) versions of these types are collectively called scalar types.

In C the scalar types are (6.2.5 Types)

21 Arithmetic types and pointer types are collectively called scalar types.

Pay attention to that in C

11 There are three complex types, designated as float _Complex, double _Complex, and long double _Complex. 43) (Complex types are a conditional feature that implementations need not support; see 6.10.8.3.) The real floating and complex types are collectively called the floating types

In C++ complex types are user-defined types that is they are defined as classes.

Also in C enumerations are included in the category of the arithmetic types while in C++ enumerations are not included in the category of arithmetic types.

And in C there is standard unsigned integer type _Bool while in C++ it is absent. On the other hand, in C++ there is the integral type bool that is absent in C.

Vlad from Moscow
  • 301,070
  • 26
  • 186
  • 335