You are on page 1of 17

The unit in procedural programming is function, and

unit in object-oriented programming is class


Procedural programming concentrates on creating
functions, while object-oriented programming starts
from isolating the classes, and then look for the
methods inside them.
Procedural programming separates the data of the
program from the operations that manipulate the data,
while object-oriented programming focus on both of
them
figure1: procedural figure2: object-oriented
Data
What

How

Why
1. Encapsulation it is the wrapping of data and associated
functions in one single unit.
2. Data Hiding- it is a related concept of data abstraction.
Unessential features are hidden from the world.
3. Abstraction it is the act of representing the essential
features without including the background details.
4. Inheritance it is the capability of one class to inherit
properties from other class.
5. Polymorphism it is the ability for data to be processed in
more than one form.
Data Encapsulation It is the Class Definition is called Encapsulation as it
will have data and methods associated as a single unit.
Data Hiding- A class groups its members into three sections: private,
protected and public. The private and protected members remain hidden from
outside world. Thus through private and protected members , a class
implements data-hiding.
Abstraction- The outside world is given only the essential and necessary
information through public members, mainly with help of public methods,
these methods implementation is abstracted to outer world and they are
exposed with simple to use application interfaces, which is nothing but
abstraction. As abstraction means representation of essential features without
including the background details.
Inheritance Derive a new class (subclass) from an existing class (base class
or superclass). Inheritance creates a hierarchy of related classes (types)
which share code and interface.Its for reusability
Polymorphism Single entity behaving in different forms is called as
polymorphism- Compile time and run time polymorphism.



Class represents structural and behavioral
representation of an object.
Class refers to a blueprint. It defines the
variables and methods the objects support
Object is an instance of a class. Each object
has a class which defines its data and behavior
In old style programming, you had:
data, which was completely passive
functions, which could manipulate any data
An object contains both data and methods that
manipulate that data
An object is active, not passive; it does things
An object is responsible for its own data
But: it can expose that data to other objects
An object contains both data and methods that
manipulate that data
The data represent the state of the object
Data can also describe the relationships between
this object and other objects
Example: A Person Class might have
An Address (it self is another class)
An BankAccount (it self is another class)

class Person
{
private:
char *name;
int Age;
int DoByear;
public:
Person(char* pname, int age, int DoByear);
void GetPersonDetails();
void DisplayPersonDetails();
void PrintPersonDetails(char *PrinterName);


};
int main()
{
Person p1("James, 13, 2000);// using constructor
Person p2;
p2.GetPersonDetails();// this will prompt the
user to enter person details
p2.name = Jack;// ERROR, its private
p2.PrintPersonDetails(Hp Printer123);
}
Access control modifiers
private: private members are accessible only in the
class itself
protected: protected members are accessible in the
class itself and in Derived/subclasses of the class
public: public members are accessible anywhere the
class is accessible
Father is an IPS
IPS is of his self owned like private, he can
only use that power
He has 10 Lakhs property which will be
inherited to his child, is like a protected
property which child also enjoys
He is good in Mathematics and he can share
with any one (public) along with his child
13
logo
american
express
hologram
card
owners name
inherits
from (isa)
visa
card
master
card
pin
category
class Employee: Person
{
int EmpID;
Int DeptID;
double salary;
void getEmpDetails() { ...}
void pay () { ...}
void PrintEmployee();
}
Every Employee has a name, age, DoBYear as well
as EmpID,DeptID, salary and a getEmpDetails, pay
method.





class Student: Person
{
int RollNo;
Int DeptID;
int Subjects[10];
int Marks[10];
void getStudentDetails() { ...}
void getStudentMarks(){}
void calculateGrade() {}
void resetmarks(int subject);
void resetmarks(int subjects[]);

}
Every Student has a name, age, DoBYear as well as
RollNo, Marks,Grade and a other methods.





1. Re Use of code- In OOP objects allows related objects to share code.
Encapsulation allows class definitions to be re-used in other
applications.
2. Ease of Comprehension The classes can be set up to closely
represent the generic application concepts and processes. OOP codes
are more near to real-world models than other programming
methodologist's codes.
3. Ease of fabrication and maintenance The concepts such as
encapsulation data abstraction allow for very clean designs.
4. Easy redesign and extension The same concepts facilitate easy
redesign and extension.
User Interface
Web page
Facebook
Abstraction
Business Layer
Database connection Database
Database
Database

You might also like