Type

Type

  • Type Classification
  • Static type
  • Dynamic type
  • Incomplete type

Type Classification

The C++ type system consists of the following types:

  • fundamental types (see also std::is_fundamental)
    • void
    • std::nullptr_t
    • arthmetic type
      • floating-point types(float,double,long double)
      • integral types
        • bool
        • character types
          • narrow character types(char,sign char,unsigned char)
          • wide character types(char16_t,char32_t,wchar_t)
      • signed integal types(short int,int,long int,long long int)
      • unsigned integal type(unsigned short int,unsigned int,unsigned long int,unsigned long long int)
  • compound types(see alsostd::is_compound)
    • reference types:
      • lvalue reference types
      • rvalue reference types
    • pointer types:
      • pointer to object types
      • pointer to function types
    • pointer to member types:
      • pointer to data member
      • pointer to member function
    • array types
    • function types
    • enumeration types
    • class types:
      • non-union types
      • union types

For every type other than reference and function,the system support three additional cv-qualified version of that types(const,volatile,const volatile)

Static type

The type of expression that results from the compiler-time analysis of the program is known as the static type of the expression. The static type does not change while the program is executing.

Dynamic type

If some glvaue expression refers to a polymorphic object, the type of its most derived object is known as the dynamic types.

// given
struct B { virtual ~B() {} }; // polymorphic type
struct D : B {}; // polymorphic type
D d; // most derived object
B* ptr = &d;
// the static type of (*ptr) is B
// the polymorphic type of (*ptr) is D

Incomplete type

The following types are incomplete type:

  • the type void
  • class type that has been declared(e.g. by forward declaration) but not defined
  • array of unknown bound(e.g. int a[][2])
  • array of elements of incomplete type
  • enumeration type from the point of declaration until its underlying type is determined.

你可能感兴趣的:(Type)