In C and C++, the typedef keyword allows you to create an alias for a known data type.
The typedef
keyword can be followed by any C and C++ built-in data type, including int
, short
, signed
, unsigned
, char
, signed char
, unsigned char
, double
, long
, or long double
. In C++, the data type can also be an existing class that either is provided by one of the libraries that ship with the C++ compiler. For example, it can be the string class. The data type can also be a pointer to a known type.