FEATURES OF OOP:

Object: Object is a collection of number of entities. Objects take up space in the memory. Objects are instances of classes. When a program is executed , the objects interact by sending messages to one another. Each object contain data and code to manipulate the data. Objects can interact without having any details of each other’s data or code.

Class: Class is a collection of objects of similar type. Objects are variables of the type class. Once a class has been defined, we can create any number of objects belonging to that class. E.g.: grapes bananas and apples are the member of class fruit.
Note: Classes are user define data types.

Data Abstraction And Encapsulation:
Combining data and functions into a single unit called class and the process is known as Encapsulation. Data encapsulation is important feature of a class. Class contains both data and functions. Data is not accessible from the outside world and only those function which are present in the class can access the data. The insulation of the data from direct access by the program is called data hiding or information hiding. Hiding the complexity of program is called Abstraction and only essential features are represented. In short we can say that internal working is hidden.

Dynamic Binding: Refers to linking of function call with function definition is called binding and when it is take place at run time called dynamic binding.

Message Passing: The process by which one object can interact with other object is called message passing.

Inheritance: it is the process by which object of one class acquire the properties or features of objects of another class. The concept of inheritance provide the idea of re usability means we can add additional features to an existing class without Modifying it. This is possible by driving a new class from the existing one. The new class will have the combined features of both the classes..

Polymorphism: A Greek term means ability to take more than one form. An operation may exhibit different behaviours in different instances. The behaviour depends upon the types of data used in the operation.
Example:
Operator Overloading
Function Overloading

Program to define class using features of OOPS in C++

#include <iostream>
#include<conio.h>
using namespace std;


class person
{

public:

  string name;
  int number;
};

//Main Function
int main()
{
    person obj;

    cout<<"Enter the Name :";
    cin>>obj.name;

    cout<<"Enter the Number :";
    cin>>obj.number;

    cout << obj.name << ": " << obj.number << endl;

    getch();
    return 0;
}

Thanks for visiting our post.

Program to define class using the features of OOP – Computer Practical
Tagged on:     

Leave a Reply

Your email address will not be published.