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]
voidLong version
Object types
Scalars
arithmetic (integral, float)
pointers:
T *for any typeTenum
pointer-to-member
nullptr_tArrays:
T[]orT[N]for any complete, non-reference typeTClasses:
class Fooorstruct BarTrivial classes
Aggregates
POD classes
(etc. etc.)
Unions:
union ZipReferences types:
T &,T &&for any object or free-function typeTFunction types
Free functions:
R foo(Arg1, Arg2, ...)Member functions:
R T::foo(Arg1, Arg2, ...)voidMember 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 typeT::* U, and it is a pointer-to-member-object ifUis a (free) object type, and a pointer-to-member-function ifUis a (free) function type.All types are complete except
void, unsized arrays and declared-but-not-defined classes and unions. All incomplete types exceptvoidcan be completed.All types can be
const/volatilequalified.The
<type_traits>header provides trait classes to check for each of these type characteristics.