Thursday, May 28, 2015

Typedef in C++

The typedef-names are aliases for existing types, and are not declarations of new types. Typedef cannot be used to change the meaning of an existing type name (including a typedef-name). Once declared, a typedef-name may only be redeclared to refer to the same type again. Typedef names are only in effect in the scope where they are visible: different functions or class declarations may define identically-named types with different meaning..



#include<iostream.h>
#include<conio.h>

typedef int usman;

typedef char name[10];

typedef struct fatima{
usman ID;
name nam;
}obj;

obj fatima1;
obj fatima2;
usman func1(usman b,usman b1)
{
name result="\nSum is= ";
usman sum;
sum=b+b1;
cout<<result<<sum;
return 0;
}

usman main(){
clrscr();
cout<<"\n Enter Two No: ";
cin>>fatima1.ID;
cin>>fatima2.ID;
cout<<"\n Enter Two Name: ";
cin>>fatima1.nam;
cin>>fatima2.nam;
cout<<"\n"<<fatima1.nam<<" "<<fatima2.nam<<"\n";
func1(fatima1.ID,fatima2.ID);
getch();
return 0;
}


Share this

0 Comment to "Typedef in C++"