Features of OOPs
Features of OOPs
(OOP)
• Class
• Object
• Comparison of Objects and Classes in C++
• Encapsulation
• Polymorphism
• Abstraction
• Inheritance
• Dynamic Binding
• Message Passing
1. CLASS: A class is a blueprint for creating objects. It defines a type of object according to
the data it holds and the operations that can be performed on it. In C++, a class is defined
using the class keyword followed by the class name and its members.
class ClassName
{
private:
// Data members (attributes)
public:
// Member functions (methods)
};
1
Comparison of Objects and Classes in C++
In Object-Oriented Programming (OOP), the concepts of classes and objects are fundamental
and closely related. Understanding their distinctions and relationship is crucial for effective
programming. Here’s a detailed comparison between objects and classes.
Example: In a car object, the method drive() abstracts the complex operations involved
in driving, presenting a simple interface to the user.
3
• Multiple Inheritance: A class inherits from more than one base class.
• Multilevel Inheritance: A class is derived from another derived class.
• Hierarchical Inheritance: Multiple classes are derived from a single base class.
• Hybrid Inheritance: A combination of two or more types of inheritance.
7. BINDING: It refers to the association between a function call and the function
definition that gets executed. Binding can be broadly categorized into two types: static
binding and dynamic binding.
STATIC BINDING (also known as early binding) refers to the process where the function
call is resolved at compile time. In static binding, the function to be called is determined
based on the type of the object as known during compilation.
Characteristics:
DYNAMIC BINDING, or late binding, refers to the process of linking a function call to
the function definition at runtime. This is commonly achieved using virtual functions.
4
Characteristics: