C++ typedef Keyword
Example
Give the int type a new name:
typedef int Number;
Number x = 5;
Number y = 10;
cout << x + y;
Definition and Usage
The typedef keyword gives an existing data type a new name (an alias). It does not create a new type, so in the example above, Number and int are exactly the same.
This is useful when a type name is long, like unsigned long long, or when a new name makes the code easier to read.
In C++11 and later, you can also write using Number = int;, which does the same thing.
Related Pages
Read more about data types in our C++ Data Types Tutorial.