Object Oriented Programming System (OOPS)

The key features of OOPS concept are:

1. Object
2. Class
3. Data Encapsulation
4. Data Abstraction
5. Inheritance
6. Polymorphism

1.Object – This is the basic unit of OOPS. Objects are the basic runtime entities. In memory, the object is a location which has some properties and functions. To create an object the first thing we have to define a class. The object can also be called as an instance of the class.

2. Class – Class contains variables(data members) and member function. Inside the particular function, we write our source code to handle our data. Inside the class, we always define object properties, variables, and functions. A class can also be defined as a blueprint for an object.

3. Data Encapsulation – Data encapsulation is the process of combining data members means variable and member function into a single unit is called data encapsulation. The most important feature of an object-oriented programming system is that we can hide our data.

4. Data Abstraction – In simple words abstraction can be explained as hiding the implementation or background activity.

Take a real-life example of a car or mobile we are using its features without looking into its background details. 

5. Inheritance – Inheritance is the process by which object of one class acquires the properties of the object of another class. Reusability of code is the best feature of inheritance.

There are 5 types of inheritance.

1. Single level
2. Multi level
3. Multiple
4. Hierarchical
5. Hybrid (Diamond Problem)

We will be learning all these concepts in detail a bit later.

6. Polymorphism: It means the ability to take more than one form. The behavior depends on the type of data used in the operation.

-> A simple addition program by class and object.

#include<iostream.h>
#include<conio.h>

class A
{
public:
void add()
{
int a,b,c;
cout<<"enter any number"<<endl;
cin>>a;
cout<<"enter any number"<<endl;
cin>>b;
c=a+b;
cout<<"sum="<<c<<endl;
}
};
void main()
{
clrscr();
A a1;
a1.add();
getch();
}

 

 

Leave a Reply