Professional Documents
Culture Documents
Object:
Polymorphism).
Now-a-days it has gained a widespread use. Like C++ many languages support
OOP like Java, PHP VB.NET, etc.
Basically there are two types of programming, namely procedural language,
that is, programs written in steps of code where C or some other languages like
Pascal uses and the second approach is OOP where C++ follows. To consider
the advantages of both, the organization of a program in the later approach is
well defined. As a programmer, you must have a basic familiarity with
programming in general, before we move forward. It is not necessary to give you
the full explanation about the current discussion, but anyhow, to some extent
and give you some indication of the flavor of the Object Oriented Programming
languages. If you dont have any knowledge of this concept, reading the major
three concepts that OOP has, will give you a better understanding.
Some authors have divided OOP into two phases that is classic and modern.
The first phase in OOP can be traced back to a language called SIMULA and
especially SIMULA 67. This language was very popular in 1960s. It was this
language that first instituted classes and objects, leading to the term Object
Oriented programming. Later, the scientist gained enough experience with OOP
and they discover some limitations of this concept. It was Xerox who developed
Smalltalk language and released it to the outside world. Smalltalk was a
pioneer language to the Graphical User Interface (GUI). Later C
language became a popular language because of the UNIX operating system
which was written in C. Basically all credit goes to the developer of C
language Denis Ritchie which became the candidate for C++ language
developed by Bjarne Stroustrup. The modern OOP working was first
completed by David Ungar and Randall Smith. After sometime, Sun
Microsystems picked up the project developed by the two scientists. But to
some extent, it did become the dominant project.
The OOP language is divided into four major concepts.
1.
Encapsulation
2.
Inheritance
3. Polymorphism
Encapsulation in C++
Encapsulation is one of the major cores of OOP. It is the mechanism that binds
code and data together and keeps them safe and away from outside inference
and misuse. In short, it isolates a data from outside world. Encapsulation can
be called as the core concept of OOP because it is encapsulation that reduces
the maintenance burden, and limiting your exposure to vulnerabilities. The
programmer has to design a well-defined interface to control the access of a
particular code and data. A class defines the data and code which is shared by
a set of objects. A class is a logical construct and an object is a physical
construct which exists in reality that is like achair or a table. A class comprises
of code and data which are collectively called members of the class.
Inheritance in C++
It is the technique used in OOP that one object acquires the properties of
another object without redefining in order to create well defined classes. This
technique also supports the hierarchical classification in which each object
would not need to be redefined by all its characteristics explicitly. It prevents
the programmer from unnecessary work and it is the inheritance concept that
does this job. Inheritance gives us the facility to an object to inherit only those
qualities that make it unique within its class. In general, it can inherit any
attributes from its parent. Again to be well noted that it is the inheritance that
get both data and functionality. We can later add any new data and methods
needed. Different names have been used in different times for a parent class
and a child class. The concept of parent and child class was developed to
manage generalization and specialization in OOP and it is represented by a is-a
relationship. But now-a-days, the following terms in object oriented
programming is commonly used names given to parent and child class.
Polymorphism in C++