My understanding: Compound type is composed of primitive and other compound types. I understand that arrays, functions, classes, unions and enumerations are compound types. Why is a pointer a compound? What primitive types is it composed of?
The C struct is the most common compound data type and organizes data contiguously in memory. A union allows the same place in memory to be treated as different types. An enum defines a list of values but acts more like a macro (see #define ) than a compound data type.
Structures, Unions, Arrays, and Pointers are the derived data types. It uses Character in the form of char, Unsigned char, Signed char, etc., for the characters present in the Fundamental Data Type. The Derived Data Types make use of pointers for storing the address of the available variables.
Pointer is a data type and the purest form of it in C is void *. A void * can pass the memory address around which is what a pointer does but it cannot be dereferenced. Dereferencing means to get at the data contained at the memory location the pointer is pointing at.
I believe the rationale can be found in the standard under "Basic concepts" (section 3 in C++14, for example):
Finally, this clause presents the fundamental types of the language and lists the ways of constructing compound types from these.
Hence a compound type is really just a type created from another underlying type. A pointer certainly meets that definition since you construct pointer-to-T
from T
.
In terms of history, it's likely that this was carried over from C since it has the same concept, though it refers to the types and object/function and derived types. Derived types there seems to mirror the same things (at least those things that are common across both languages), including pointers.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With