The typedef (meaning type definition) command allows the programmer to define a new name for a particular type.
In reality, this keyword to create a synonym, which is different from creating a new type. typedef is followed by the name of the existing type and then alias and a semicolon. Its general form is:
typedef unsigned short int USHORT;
Now there is also another data type which is known as USHORT and which is the Reference to the unsigned short int. Means Now we can also use USHORT instead of unsigned short int data type.
// Demonstration of the use of the keyword typedef
#include <iostream.h>
#include<conio.h>
typedef unsigned short int USHORT; // alias definition
int main ()
{
clrscr();
USHORT width = 5;
USHORT length;
length = 10;
USHORT Area = width * length;
cout << "Width :" << width<<endl;
cout << "Length :"<< length <<endl;
cout << "Area :" <<Area << endl;
return 0;
}
This program producesthe following result