



Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!




OOP Principles or Basic Concepts of OOP The prime purpose of C++ programming was to add object orientation to the C programming language, which is in itself one of the most powerful programming languages. The core of the pure object-oriented programming is to create an object, in code, that has certain properties and methods. While designing C++ modules, we try to see whole world in the form of objects. For example a car is an object which has certain properties such as color, number of doors, and the like. It also has certain methods such as accelerate, brake, and so on. There are a few principle concepts that form the foundation of object-oriented programming โ Objects Classes Data abstraction Data encapsulation Inheritance Overloading Polymorphism Dynamic binding Message passing Objects: Objects are basic building blocks for designing programs. An object may represent a person, place or a table of data. An object is a collection of data members and associated member functions. Each object is identified by a unique name. Every object must be a member of a particular class. Ex: Apple, orange, mango are the objects of class fruit. Objects take up space in memory and have address associated with them. For example, structure variable in a C program. At the time of execution of a program, the objects interact by sending messages to one another. The objects can interact with one another without having to know the details of data or functions within an object. Classes: The objects can contain data and code to manipulate the data. The objects can be made user defined data types with the help of a class. Therefore, objects are variables of the type class. A class is a way of grouping objects having similar characteristics. Once a class is defined, any number of objects of that class are created. For example, planets, sun, moon are
members of class solar system. Classes are user defined data types. A class can hold both data and functions. Data abstraction: Data abstraction permits the user to use an object without knowing its internal working. Abstraction refers to the process of representing essential features without including background details or explanations. Classes use the concept of abstraction and are defined as a list of abstract attributes such as size, weight and cost, and functions to operate on these attributes. Data encapsulation : Data encapsulation combines data and functions into a single unit called class. Data encapsulation will prevent direct access to data. The data can be accessed only through methods (function) present inside the class. The data cannot be modified by an external non-member function of a class. Data encapsulation enables data hiding or information hiding. Inheritance : 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. Thus the process of forming a new class from an existing class is known as Inheritance. The objects of one class acquire the properties of another class through inheritance. The existing class is known as base class. The new class is known as derived class. The derived class shares some of the properties of the base class. Therefore, a code from a base class can be reused by a derived class. In addition to this the new class may combine features from two different base classes too. In single inheritance, each subclass has only one superclass. In Multiple inheritance, each subclass has more than one super class.
Message Passing: In OOP, processing is done by sending messages to objects. A message for an object is request for execution of procedure. The request will involve a procedure (function) in the receiving object that generates desired results. Message passing involves specifying the name of object, the name of the function (message) and the information to be sent. Advantages of OOP :