by Dinesh Thakur Category: Object-oriented programming (OOP)

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

Typedef



About Dinesh Thakur

Dinesh ThakurDinesh Thakur holds an B.SC (Computer Science), MCSE, MCDBA, CCNA, CCNP, A+, SCJP certifications. Dinesh authors the hugely popular blog. Where he writes how-to guides around Computer fundamental , computer software, Computer programming, and web apps. For any type of query or something that you think is missing, please feel free to Contact us.



Related Articles