User defined type is a way from which help an user can create variables of own type.
There is two way for creating user defind data type:
1. Using typedef keword
2. Using enum keyword(enumerated data type).
1.typedef----
typedef existing_data_type new_userdefined_type;
e.g
typedef int krish;
krish a,b,c;/* a,b,c are integer variable*/
we can further use keyword typedef to create new data type from datatype being used as:
typedef krish kg;
kg l,m; /* l,m are integer variable*?/
typedef with structures:
typedef struct class
{
……..
……..
} my;
function()
{
class var1,var2; /*simple object declaration*/
my var3; /*declaration using dublicate datatype i.e user type*/
}
2.Enumerated datatype:
Enum cricket(sachin,rahul,shehbag,…..,dhoni);
cricket a,b,c;
a=sachin; /*valid*/
b=10; /*invalid*/
c=jaysurya; /*invalid*/