There are some derived data types which are user defined. Examples of these data types are :
Class,
structures,
unions and
enumerations. Thogh we will have a detailed discussion of these topics in the coming tutorials. But let us a short review of these topics.
- Class:
A class is a group of similar or dissimilar elements that are referenced under the same name. The variables under these names may be different. For example, consider this: class student
{
int roll_no;
char name;
float percentage;
char subjects
};
In this example we see that this class student contains four dissimilar elements under the same name, i.e 'student'. All these four elements are of different types such as roll_no of int type, name of character type and so on.
- Structures :
Structure is very similar to class. This is also a collection of similar or dissimilar elements which are referenced under the same name. Now there arises a question in your mind. What is the need to tell about structures when it is very similar to class. Yes you are right it is very similar to class. But there is a little difference between them. They differ by visibility modes. We will discuss about the visibility mode in details when we will study about classes and structures. An example for structure can be given as structure student
{
int roll_no;
char name;
float percentage;
char subjects
};
No comments:
Post a Comment