### typedef

A typedef declaration lets you define your own identifiers that can be used in place of type specifiers such as int, float, and double. The names you define using typedef are not new data types. They are synonyms for the data types or combinations of data types they represent.

A typedef declaration does not reserve storage.

When an object is defined using a typedef identifier, the properties of the defined object are exactly the same as if the object were defined by explicitly listing the data type associated with the identifier.

The following statements declare `LENGTH` as a synonym for int, then use this typedef to declare length, width, and height as integral variables.

>     typedef int LENGTH;
>     LENGTH length, width, height;

The following declarations are equivalent to the above declaration:

>     int length, width, height;

Similarly, you can use typedef to define a struct type. For example:

>     typedef struct {
>                     int scruples;
>                     int drams;
>                     int grains;
>                    } WEIGHT;

The structure `WEIGHT` can then be used in the following declarations:

>     WEIGHT chicken, cow, horse, whale;

In C++, typedef can also be used to define a union or C++ class.

A C++ class defined in a typedef without being named is given a dummy name and the typedef name for linkage. Such a class cannot have constructors or destructors. For example:

    typedef class {
                   Trees();
                  } Trees;

Here the function Trees() is an ordinary member function of a class whose type name is unspecified. In the above example, Trees is an alias for the unnamed class, not the class type name itself, so Trees() cannot be a constructor for that class.

Type Specifiers