User-defined data type, C/C++ Programming

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”;

}

Posted Date: 9/20/2012 7:32:15 AM | Location : United States







Related Discussions:- User-defined data type, Assignment Help, Ask Question on User-defined data type, Get Answer, Expert's Help, User-defined data type Discussions

Write discussion on User-defined data type
Your posts are moderated
Related Questions
Ask question #Minimum 100 what is friend function is used in c++

I am working on a program that allows a player to play a game against the computer. In this game the player can only chose to draw 1, 2, or 3 toothpicks. How do I make restrictions

Rules for overloading an operator This summarizes the most significant points you need to know in order to do operator function overloading. The only operators you may o

Write a simple program in C++ to investigate the safety of its enumeration types. Include at least 10 different operations on enumeration types that are incorrect/unsafe things to

Define Generic Bitwise Operations? Bitwise operators only work on an incomplete number of types int and char. It turns out there's above one kind of int. In particular there's

Develop a program to meet the following requirements: 1. Must use at least one function in addition to main (you can use more) 2. Must use selection 3. Must use deference/indire

Create a program that will accept 3 numbers. The first number (num1) is the common difference and the second number (num2) is the starting number and the 3rd number (num3) is the m

In this project, you will write a software for the Registrar's office of a university called YouOIT to maintain information about students and courses at the university. The reg

A Padovan string P(n) for a natural number n is defined as: P(0) = ‘X’ P(1) = ‘Y’ P(2) = ‘Z’ P(n) = P(n-2) + P(n-3), n>2 where + denotes string concatenation. For a string of the c

Program is to read the characters from keyboard: Program is to read the characters from keyboard one by one stored in different files as upper constants, lower constants, othe