tags:

views:

85

answers:

1

Arrays, functions, pointers, references, classes, unions, enumerations and pointers to members are compound types.

My understanding of a compound type is that is based on other type(s). For example, T[n], T* and T& are all based on T. Then what other type(s) is an enumeration based on?

Or if my understanding of compound types is incorrect, what exactly is it about a type that makes it a compound type? Is compound simply a synonym for user-defined?

+8  A: 

In C++ enum types are scalar types, yet at the same time they are compound types since they are built on top of some fundamental integral type. In case of an array or pointer you specify "base" type explicitly, but in case of an enum the specific underlying integral type is chosen implicitly and automatically by the implementation. You have no manual control over the underlying integral type, which still doesn't disqualify enum types from being compound in nature.

Some compilers (as well as future C++ standard C++0x) allow user to specify the underlying integer type for given enum type, which makes it more obvious that it is in fact a compound type. See here for examples like

enum class Color : char { red, blue };
AndreyT