View Single Post
Old 07-10-2007, 07:27 AM   #312 (permalink)
QwertyManiac
Commander in Chief
 
QwertyManiac's Avatar
 
Join Date: Jul 2005
Posts: 6,658
Default Re: Post ur C/C++ Programs Here

Typedef is commonly used to give any Data Type a new name.

Like for example:
Code:
#include<iostream>
int main()
{
    typedef int a;  // Thus, a refers automatically to an integer
    a abc=1, def=0; // Creates two variables of type int,
                              // as the typedef above shows
    cout<<"ABC = "<<abc<<" DEF = "<<def<<endl;
    return 0;
}
This is very useful while working with a lot of classes, or structures. You can name them comfortably or for different usages (Like we use Position and List names in a clear Linked List algorithm but both are essentially the same structure, just used with a different name to aide understanding).

Last edited by QwertyManiac; 07-10-2007 at 09:29 AM.
QwertyManiac is offline