Why is pointer a compound type, not a fundamental type?
-
Compound types, by definition, are types that are derived from other basic types. Right? In my opinion, pointers, with their unique representation( * and &), must be classificated as a fundamental type. Am I wrong?
sawerr wrote:
Compound types, by definition
Interestingly, Bjarne Stroustrup does not provide a definition in his glossary of C++[^].
-
Compound types, by definition, are types that are derived from other basic types. Right? In my opinion, pointers, with their unique representation( * and &), must be classificated as a fundamental type. Am I wrong?
A pointer is not a type. Otherwise you would be able to create it this way -
* p;
«_Superman_» _I love work. It gives me something to do between weekends.
-
Compound types, by definition, are types that are derived from other basic types. Right? In my opinion, pointers, with their unique representation( * and &), must be classificated as a fundamental type. Am I wrong?
Since a pointer is a memory address its type if you lie is actually its size, and hence is the same as the bit ness of the OS, 32 or 64, 4 or 8. However, and this is where it gets interesting, when you increment a pointer the address increases by the size of the declared type. So a char pointer goes up by one byte, a DWORD pointer by 4 and so on.