Object-oriented programming (oop) is a programming paradigm that represents the concept of
“object” that have data fields (attributes that describe the object) and associated procedures known as
methods.
An object can be considered a “thing” that can perform a set of related activities. The set of activities
that the object performs defines the object’s behaviour. For example, the hand can grip something or
a student (object) can give the name or address .
Features of opps.
- Class and object:- A class is a blueprint that describes characteristics and function of entity.. for example, the class dog would consist of traits shared by all dogs. A class is collection of the properties and methods are called members. Object is an instance of class.
- Data abstraction:– it is a process that provides only essential features by hiding its background details. A data abstraction is a simple view of an object that includes required features and hides theunnecessary details.
- Data encapsulation:– it is a machine of bundling the data , and the functions that use them and data abstraction is a mechanism of exposing only the interface and hiding the implementation details from the user. C++ supports the properties of encapsulation and the data hiding through the creation of user-defined types, called classes. We already have studied that a class can contain private, protected and public members. By default, all items defined in a class are private.
For example:–
Class pix
{
Private:
int a,c;b
public:
void sum()
{
}
};
- Inheritance:- it is a process to create a new class from existing class or classes. Class ‘B’ is a sub
class that is derived from class ‘A’. thus class ‘A’ is a parent class and class ‘B’ is a child class. It
provides reusability of code.
- Polymorphism:– Generally, it is the ability to appear in different forms. In oops concept, it is the ability to process object differently depending on their data types. It’s the ability to redefine methods for derived classes.
Advantage:–
- Reusability of code
- Easy to maintenance.
Post Views: 4,100