Thursday, December 21, 2006

CLASS AND OBJECTS

CLASS

The basic difference between C and C++ is class. It is somewhat difficult to understand in first sight. But I assure you that it is very easy to understand. Read all the material, you will find each and every thing difficult initially but gradually your ride will become smother.
It is very important feature of object oriented programming. Class is used in c++ to create user defined data. Class is a technique to combine object functionality and properties at one place. By using it we can bind different data member and method in one unit. After that we use make the object of a class and use it in the program.
In simple word we can say to represent any object of this world in the program is called class.

Syntax
Class class-name
{
vis mode : (private)
Data member(variable)
Member function (fun)
Vis mode : (public)
Data-member(variable)
Member fun(fun methods)
};

In class the variable which is used to store the importance of object is called Data member. And for performing different types of operation on a object, function which is used is called Member function.


Visibility Mode

They are two types of visibility mode:-
a. Private
b. Public

Private :- This is class default mode. When we without writing any visibility mode define some variables it will always goes in Private. We cannot use class private members outside the class. They can be used with the class members.

Public :- To make a member type of public we used public visibility mode. It can be used outside class also. Usually Data member is made in private and member function made public. I will define it later the reason behind it.

Program

Return to main menu

No comments: