explain user-defined data typesc has union and


Explain User-Defined Data Types?

C has Union and Structure as user-defined data types.  C++ has class which looks like

structure with additional feature to it.  A class can have functions and structure declared to it. This is the foundation for the Object-Oriented programming.

Enumerated data type is also a derived data type.   It is declared like in C with certain added features.  In C we can define a typedef.

typedef int mark;

mark phy,chem,mat;

enum day = { Monday, Tuesday, Wednesday, Thursday, Friday, Saturday, Sunday };

 

In C++ the variable day can be used as typedef.

day daysofweek; is a valid statement in C++.  This mean a same enumerated data type is declared from the original. It is similar to declaring another variable of same type.   The default value for an enumerated data type starts with zero.  It can be changed by assigning the value.

enum dept {CSE=104,EEE=105,ECE-106};

enum dept {CSE=104,EEE,ECE-106}; EEE will be 105

enum dept {CSE,EEE=105,ECE-106}; CSE will be 0 enum dept {CSE=101,EEE,ECE-106}; EEE will be 102 enum onoff{on, off};

 

Enumeration is used as symbolic constant in switch. enum dept {CSE=104,EEE=105,ECE-106}; int main ( )

{int depts;

cin >>depts;

if depts == CSE;

cout <<”Computer Science and Engineering”;

}

Request for Solution File

Ask an Expert for Answer!!
C/C++ Programming: explain user-defined data typesc has union and
Reference No:- TGS0161111

Expected delivery within 24 Hours