Class is an example of underdefined data type through which we can achieve data abstraction.Data abstractions the curical step of representing information in terms of its interface with the user itis a short step to the user-defined type.
In short data type can be viewed in two terms.
1. It determine how much memory will be needed for a data object
2. IT determines what operations or methods can be performed using the data object.
For built in types this information is built in to the compailer.But when you defined type in c++,you have to provide the same kind of information yourself.In eschange for this kind of work you gain the power and flexibility to custom fit new data types to match real world requirements.
The class is the concept available in c++ through which we can achieve this goal.
A class basically includes two things the data member functions or the operations that are to be performed with that data.Tha member functions of the class are also termed as class methods.The Wrapping of data and methods in to one single entity is called as encaosulation.The decleration of class include two additinal keywords private and public.The keywords are useful in discribing the"VISABLITY or"ACCESSIBILITY of class members .The data members can be declared either in the private or public section of class .But because one of the main OOP precepts is to hide data.The data items normally goo in to the private section.The member functions that constitute the class interface of into public section.
The insulation of data from direct access by a program is called data hiding
A class definition has this form:
class
{
private :
data members declarations;
public :
member functions ;
};
Even it is possible to just provide function prottype inside the class and function body outsie the class for which you just need to use the scope resolution operator to indicare to which class a member function belongs.
ARRAY OF OBJECTS:
IT IS CONCEPT BY WHICH we try to declare aray of objects .Arrys canhold few data itms of tens of thosands.The data items grouped in an array can be simple types like int or they can be user defined types of like structure or objects.
consider the followinf class defination,
class Employee
{
char name[30];
floar age;
public:
void get data(void);
void put data(void);
};
The identifier employee is auser define data type and can beused to create objects the relate to different categories of the employees.
No comments:
Post a Comment