C++ Programming Language:
C++
is an object oriented programming language. It mainly emphasis on object rather
than procedure. C++ overcomes limitation of C programming language. OOP is an approach
to program organization and development which attempt to eliminate some of
drawbacks of structured programming like procedure oriented programming. The
main limitations of procedure language(C) are:
--> Emphasis on procedure (i.e. Algorithm).
--> Emphasis on procedure (i.e. Algorithm).
--> Most of the function share global data.
--> Data move openly from function to function.
--> Function can change data of another function.
To
remove such limitation of procedural language, OOP is invented. OOP treats data
as a critical element in the program development and does not allow it to move
freely around the system. It ties data more closely to function that operate on
it and protect it from accidental modification from outside function. OOP allow
decomposition of problem into a number of entities called objects and build
fata and function around the objects. The data of an object can be accessed
only by the function associated with the object.
Feature of procedural oriented programming:
The
main characteristics of procedural programming are:
-->
Emphasis on procedure.
-->
Large program are divided into smaller program known as function.
-->
Most of the function share global data.
-->
Data move openly around the system from function to function.
-->
Function can transform data from one form to another.
-->
Employees top-down approach in program design.
Features of OOP:
The
key features of OOP are:
1)
Object
2)
Class
3)
Inheritance
4)
Polymorphism
5)
Encapsulation
6)
Message Passing
1) Object:
Object
are the entities in an object oriented system through which we perceive the
word around us. We naturally see our environment as being composed of entities (things)
which have recognizable identities and behavior. The entities are then
represented as object in the program. They may represent a person, place, bank
account or any item that the program must handle. Example:
Object:
Student
|
Data:
Name
Roll
No.
Date
of birth
Marks
|
Function:
Total()
Average()
Display()
|
2) Class:
A
class is a collection of object of similar type. Example: Manager, peon, clerk are
member of the class employee and class vehicle include object car, bus,
bicycle, etc. It defines a data type much like in C programming language. It
specifies what data and function will include in object of that class.
3) Inheritance:
Inheritance
is the process by which object of one class acquire characteristics of object
of another class. In OOP, the concept of inheritance provides the idea of
reusability we can add additional feature to an existing class without
modifying it. This is possible by deriving new class (derived class) from
existing one (base class). The process of deriving new class from existing base
class is called inheritance.
4) Polymorphism:
Polymorphism
means having multiple forms. The polymorphism allow different object to respond
to the same message in different way. The response specific to the type of object
.Polymorphism is important when object oriented program dynamically destroy and
create object. Example of polymorphism in OOP is operator overloading and
function overloading.
5) Dynamic Binding:
Binding
refer to linking of the function to the code to be executed in response to
call. Dynamic binding means that code associate with given function call is not
known until run time. It is associated with polymorphism and inheritance.
6) Message Passing:
An
object oriented program consists of set of object that communicates with each
other. Object communicates with each other by sending and receiving message. A
message for an object is a request for execution of a procedure and therefor
will involve a function or procedure in receiving object that generate the
desired result. Message passing involve specifying the name of object, name of
function and information to be send. Example: Object-function name
(information).
Advantage of OOP:
-->
Making the use of inheritance, redundant code is eliminated.
-->
Through the data hiding, Programmer can build secure program.
--> System can be easily upgraded from small to large system.
--> Software complexity can be easily managed.
-->
Code reusability is much easier than conventional programming language.
No comments:
Post a Comment