Anu. S
anusdhar4@gmail.com
www.facebook.com/AnuSasidharan
twitter.com/username
in.linkedin.com/in/profilename
OOPS CONCEPTS IN C++
Disclaimer: This presentation is prepared by trainees of
baabtra as a part of mentoring program. This is not official
document of baabtra –Mentoring Partner
Baabtra-Mentoring Partner is the mentoring division of baabte System Technologies Pvt . Ltd
CONTENTS
OBJECT ORIENTED PROGRAMMING
DATAABSTRACTION
INHERITANCE
DATA ENCAPSULATION
POLYMORPHISM
EXAMPLE
OBJECT ORIENTED
PROGRAMMING
Object oriented programming approach views a
problem in terms of objects involved.
OBJECTS
An OBJECT is an identifiable entity with some
characteristics and behaviour.
Example: Orange
Characteristics: spherical shape
orange colour
Behaviour: juicy
tastes sweet-sour
CLASS
A CLASS is a group of objects that share common
properties and relationships
Example: a CAR can be considered as
a class.
Objects in this class involves the
steering,wheels,engine.
Properties involve the
company,color,model,speed,engine
capacity,etc
EXAMPLE
class CS{
int studentid;
char name[100];
int totmks=0;
float avg;
int total(int marks[5])
{
for(i=0;i<5;i++)
{
totmks+=marks[i];
avg=totmks/5;
}
return balance;
}
};
class
objects CS stud1,stud2;
DATA ABSTRACTION
DATAABSTRACTION
The act of representing essential features without including the
background details or explanations.
Example:
A calculator
Only the results are displayed on the
screen
The user is unaware of its internal
processing
INHERITANCE
The capability of
one class of
things to inherit
capabilities or
properties from
another class.
INHERITANCE
VEHICLES
automobiles Pulled vehicles
ENCAPSULATION
ENCAPSULATION
The wrapping up of data and operations or functions
into a single unit .
ENCAPSULATION
DEPARTMENT
PRODUCTION
PURCHASE
SALES
ACCOUNTS
MEMO
POLYMORPHISM
POLYMORPHISM
The ability for a data to be processed in more than one
form.
POLYMORPHISM
SHAPE
AREA()
CIRCLE
AREA(CIRCLE)
TRIANGLE
AREA(TRIANGLE)
RECTANGLE
AREA(RECTANGLE)
EXAMPLES
#include<iostream.h>
class Item{
int itemno;
float price;
public:
void getdata(int i,float j)
{
itemno=i;
price=j;
}
};
const int size=10;
Item order[size];
int main()
{
int ino;
float cost;
//get value for all items
for(int a=0;a<size;a++)
{
cout<<"Enter itemno & price for item"<<a+1<<"n";
cin>>ino>>cost;
order[a].getdata(ino,cost);
}
return 0;
}
Item 1
Itemno:111 price:155
Item 2
Itemno:125 price:89
Item 3
Itemno:201 price:95
Item 4
Itemno:352 price:213
Item 5
Itemno:444 price:250
THANK YOU...
Want to learn more about programming or Looking to
become a good programmer? Are you wasting time on
searching so many contents online? Do you want to learn
things quickly? Do an online course @ baabtra.com. We
provide development, testing and production environments
just like in the industry to practice. The courses are so
structured to make a quick, good software professional.
Follow us @ twitter.com/baabtra
Like us @ facebook.com/baabtra
Subscribe to us @ youtube.com/baabtra
Become a follower @ slideshare.net/BaabtraMentoringPartner
Connect to us @ in.linkedin.com/in/baabtra
Thanks in advance.
www.baabtra.com | www.massbaab.com |www.baabte.com
Contact Us
Emarald Mall (Big Bazar Building)
Mavoor Road, Kozhikode,
Kerala, India.
Ph: + 91 – 495 40 25 550
NC Complex, Near Bus Stand
Mukkam, Kozhikode,
Kerala, India.
Ph: + 91 – 495 40 25 550
Cafit Square,
Hilite Business Park,
Near Pantheerankavu,
Kozhikode
Start up Village
Eranakulam,
Kerala, India.
Email: info@baabtra.com

Oop cocepts