Professional Documents
Culture Documents
Main Program
Function-4 Function-5
Function-6
Data Data
Communication
Functions Functions
Object C
Data
Functions
Difference Between Procedure Oriented Programming
& Object Oriented Programming
Difference Between Procedure Oriented Programming (POP) & Object Oriented Programming
Two Programming Paradigms
Structural (Procedural) Object-Oriented
PROGRAM PROGRAM
FUNCTION OBJECT
Operations
FUNCTION Data
OBJECT
OBJECT Operations
FUNCTION
Operations Data
Data
Function calls Messages passing
9
OOPS Principles
• Objects
• Classes
• Data Abstraction and Encapsulation
• Polymorphism
• inheritance
What is an object?
Objects are the runtime entities of a class or an
instance of a class.
OBJECT
set of methods
Operations (member functions)
11
Class
• Consists of both data and methods
• The entire set of data and code can be made as a
user-defined type with the help of a class. Once a
class has been defined, we can create any number of
objects belonging to that class.
Declaration of an Object
class Rectangle
main()
{ {
private: Rectangle r1;
Rectangle r2;
int width;
int length; r1.set(5, 8);
public: cout<<r1.area()<<endl;
13
Declaration of an Object
class Rectangle
main()
{ {
private: Rectangle r1;
Rectangle r2;
int width;
int length; r1.set(5, 8);
public: cout<<r1.area()<<endl;
14
• For example, the object for Rectangle class
can be created as follows:
Rectangle r1;
• Four Wheeler
Car Jeep
Polymorphism
• Ability to take more than one form.