C++ Programming Tutorials - Object Orientated Programming (OOD)

BASIC CONCEPTS OF OBJECT-ORIENTED PROGRAMMING

Data Abstraction and Encapsulation

The wrapping up of data and functions into a single unit (called class) is known as encapsulation. Data encapsulation is most striking feature of a class. The data is not accessible to the outside world, and only those functions which are wrapped in the class can access it.

These functions provide the interface between the object’s data and the program. This insulation of the data form direct access by the program is called data hiding or information hiding.

Abstraction refers to the act of representing essential features without including the background details or explanations.

Classes use the concept of abstraction and are define as al list of abstract attributes such as size, weight and cost, and functions to operate on these attributes.

C++ Inheritance

Inheritance is the process by which objects of one class acquire the properties of objects of another class. It supports the concept of hierarchical classification.

In OOP, the concept of Inheritance provides the idea of reusability. This means that we can add additional features to an existing class without modifying it. This is possible by deriving a new class form the existing one. The new class will have the combined features of both the classes.

The real appeal and power of the inheritance mechanism is that it allows the programmer to reuse a class that is almost, but not exactly, what he wants, and to tailor the class in such a way that it does not introduce any undesirable side-effects into the rest of the class.

C++ Polymorphism

Polymorphism is another important OOP concept. Polymorphism, a Greek term, means the ability to take more one form. An operation may exhibit different behaviors in different instances. The behavior depends upon the types of data used in the operation.

Polymorphism plays an important role in allowing objects having different internal structures to share the same external interface.

This means that a general class of operations may be accessed in the same manner even though specific actions associated with each operation may differ. Polymorphism is extensively used in implementing inheritance.

C++ Tutorial: Object Orientated Programming (OOD)