July 10, 2011

Object oriented programming language (OOPL) and Run time Polymorphism

Object oriented programming language (OOPL)

What is object in c++

Objects are the foundation of object-oriented programming, and are fundamental data types in object-oriented programming languages. These languages provide extensive syntactic and semantic support for object handling, including a hierarchical type system, special notation for declaring and calling methods, and facilities for hiding selected fields from client programmers. However, objects and object-oriented programming can be implemented in any language.

C++ Carry's the concept of object oriented programming
1) data abstraction
2) data encapsulation
3) modularity
4) inheritance
5) polymorphism

C++ is an OOPL not just because it supports the OOPS concepts but more importantly, those concepts are EASY to implement in C++, and sometimes some non OOPS concepts are difficult to do.

For example, it is possible to implement data hiding etc using C, but they are unusually difficult, whereas C++ directly supports the concept of access modifiers etc.

OOP language is one that allows or encourages, to some degree, object-oriented programming techniques such as encapsulation, inheritance, modularity, and polymorphism.

C++ is entirely differ from C
C++ is an OOP Language designed mainly for OO programming, but with some procedural elements.So clearly it is an Object oriented programming language.

Object-oriented (OO) applications can be written in either conventional languages or OOPLs, but they are much easier to write in languages especially designed for Object-oriented programming. Object-orientedlanguage experts divide OOPLs into two categories, hybrid languages and pure Object-orientedlanguages. Hybrid languages are based on some non-Object-oriented model that has been enhanced with Object-oriented concepts. C++ (a super set of C), Ada 95, and CLOS (an object-enhanced version of LISP) are hybrid languages. Pure Object-oriented languages are based entirely on Object-oriented principles; Smalltalk, Eiffel, Java, and Simula are pure Object-oriented languages.

everything that can be done using C++ can be done using C - that includes data-hiding as well. Its just that there are no explicit key words to support. That's the reason why C++ is preferred - because of these explicit keywords. Also, like I said before, "object-oriented language" is a loose term. It is either hybrid or pure OO. C++ is hybrid because it supports multiple styles of programming. Java on the other hand will not allow you to write a program that does not have a class. Hence Java is a pure object oriented language (though some people question that because Java supports primitive keywords like int whereas in Eiffel even Integer is implemented as a class).

c++ is not a pure object oriented programming language.
It is a object based programing language.
In c++ language we can write programs without using the class concepts.
But it is not possible in java,c#.net. They are purely object oriented programing language. If we want to write a programme for simple addition also we must using the class concept. But in c++ not like that.

Run time Polymorphism

Suppose you have written a base class from which a number of class have been derived,as i understand that,in real life scenario the number of such derived can be overwhelming. To handle objects of each class individually can be very cumbersome not mention near nigh impossible.Run time polymorphism gives us respite from this problem as using the base class pointer we can call functions in derived classes that have been declared virtual in the base class.

It is worth remembering that implementation of a virtual function call rather resembles an indirect function call but with one exception and that is the flexibility in coding that can be achieved by this implementation.

To know more about Polymorphism click on link below