Wednesday, 11 January 2012

Classes


One of the major problems in the earlier approach was also the data and the functions working upon the data being separate. This leads to the necessity of checking the type of data before operating upon the data. The first rule of the object-oriented paradigm says that if the data and the functions acting upon the data can go together let them be together. We can define this unit, which contains the data and its functions together as a class. A class can also be defined as a programmatic representation of an entity and the behavior of that entity can be represented by the functions in the class. In our earlier case study the employee, can be represented as a class. A class will contain its data into various variables, which would be termed as data members and the behavior of
the class, which will be encapsulated, as functions will be termed as member functions.