Tuesday, October 14, 2008

Necessity for Object Oriented Programming Language.

What is the necessity for Object Oriented Programming Language?

In simple terms,  why we have moved from C(Procedural Language) to C++(Object Oriented Language)  ?

In C we use user defined data types like Structure, Union etc, where as in C++ we use classes, here I will try to answer the above question in terms of using these different language elements:

1. The variables we use in a structure or union can be accessed any where in the program, this means,  that there is no proper security for data in C i.e. Procedural Langauage. Where as in c++ we have access specifiers like public, private, protected etc, which allows us to restrict the access to a particular variable. So unlike C, C++ has some control over the access to the data.

2. The variables/ elements of one structure are cannot be accessed in an other structure unless they are nested, so there is some access limitations for data in C. Where as in C++ the variables declared and used in one class are allowed/ restricted to get accessed by other classes throught the same access specifiers public, private, protected etc.

3. Function concepts is not supported by structures in C i.e, we cant declare a function as a structure member, where classes can have functions as their members. 

These are a few reasons, where there is a necessity to move from a structure oriented language to a object oriented language.