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
Week Target Achieved
1 30 20
2 30 22
3 30
Typing Speed
OOPconcepts
Yasirmusthafapp
yasirmusthafapp@gmail.com
www.facebook.com/yasirmusthafa
twitter.com/yasirmusthafapp
in.linkedin.com/in/yasirmusthafapp
8891396749
Introduction
• Purpose of c++ - To add object orientation to c
programming
The concepts
• Objects
• Class
• Abstraction
• Encapsulation
• Inheritance
• Polymorphism
objects
• Basic unit of oop concept
• Both data and function are bundled as a unit
Class
• Blue print of object
• What an object consist of-
• What operation can be performed-
Encapsulation
• Mechanism of bundling the data and function
that use them
• Data binding
• Keep both safe from outside interference and
misuse
• Led to data hiding
Abstraction
• Mechanism of exposing only the interfaces
and hiding the implementation details
Example
class Box {
public:
double getVolume(void) {
return length * breadth * height;
}
private:
double length; // Length of a box
double breadth; // Breadth of a box double
height; // Height of a box
}
Inheritance
• Code reusability
• Process of forming a new class from an
existing class
existing class-base class
new class – derived class
• is a - relationship
Example// Base class
class Shape {
public:
void setWidth(int w) {
width = w;
}
void setHeight(int h) {
height = h;
}
protected:
int width;
int height;
};
Inheritance (conti)
// Derived class
class Rectangle: public Shape {
public: int getArea() {
return (width * height);
}
};
int main(void) {
Rectangle Rect;
Rect.setWidth(5);
Rect.setHeight(7);
// Print the area of the object.
cout << "Total area: " << Rect.getArea() << endl; return 0;
}
Polymorphism
• Ability to use an operator or function in
different ways
• Single function or an operator functioning in
many ways different upon the usage
Example
class Shape {
protected:
int width, height;
public:
Shape( int a=0, int b=0) {
width = a;
height = b;
}
virtual int area() {
cout << "Parent class area :" <<endl;
return 0;
}
};
Polymorphism(conti)
class Rectangle: public Shape{
public:
Rectangle( int a=0, int b=0):Shape(a, b) { } int area () {
cout << "Rectangle class area :" <<endl;
return (width * height); }
};
class Triangle: public Shape{
public:
Triangle( int a=0, int b=0):Shape(a, b) { }
int area () {
cout << "Triangle class area :" <<endl;
return (width * height / 2);
}
};
Polymorphism(conti)
// Main function for the program
int main( ) {
Shape *shape;
Rectangle rec(10,7);
Triangle tri(10,5);
// store the address of Rectangle
shape = &rec;
// call rectangle area.
shape->area();
// store the address of Triangle
shape = &tri;
// call triangle area.
shape->area();
return 0;
}
Thank you
If this presentation helped you, please visit our
page facebook.com/baabtra and like it.
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
Start up Village
Eranakulam,
Kerala, India.
Email: info@baabtra.com
IKK Road,
East Hill, Kozhikode
Kerala, India.
Ph: + 91 – 495 30 63 624
NIT-TBI,
NIT Campus, Kozhikode,
Kerala, India.

Oop concept

  • 2.
    Disclaimer: This presentationis 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
  • 3.
    Week Target Achieved 130 20 2 30 22 3 30 Typing Speed
  • 4.
  • 5.
    Introduction • Purpose ofc++ - To add object orientation to c programming
  • 6.
    The concepts • Objects •Class • Abstraction • Encapsulation • Inheritance • Polymorphism
  • 7.
    objects • Basic unitof oop concept • Both data and function are bundled as a unit
  • 8.
    Class • Blue printof object • What an object consist of- • What operation can be performed-
  • 9.
    Encapsulation • Mechanism ofbundling the data and function that use them • Data binding • Keep both safe from outside interference and misuse • Led to data hiding
  • 10.
    Abstraction • Mechanism ofexposing only the interfaces and hiding the implementation details
  • 11.
    Example class Box { public: doublegetVolume(void) { return length * breadth * height; } private: double length; // Length of a box double breadth; // Breadth of a box double height; // Height of a box }
  • 12.
    Inheritance • Code reusability •Process of forming a new class from an existing class existing class-base class new class – derived class • is a - relationship
  • 13.
    Example// Base class classShape { public: void setWidth(int w) { width = w; } void setHeight(int h) { height = h; } protected: int width; int height; };
  • 14.
    Inheritance (conti) // Derivedclass class Rectangle: public Shape { public: int getArea() { return (width * height); } }; int main(void) { Rectangle Rect; Rect.setWidth(5); Rect.setHeight(7); // Print the area of the object. cout << "Total area: " << Rect.getArea() << endl; return 0; }
  • 15.
    Polymorphism • Ability touse an operator or function in different ways • Single function or an operator functioning in many ways different upon the usage
  • 16.
    Example class Shape { protected: intwidth, height; public: Shape( int a=0, int b=0) { width = a; height = b; } virtual int area() { cout << "Parent class area :" <<endl; return 0; } };
  • 17.
    Polymorphism(conti) class Rectangle: publicShape{ public: Rectangle( int a=0, int b=0):Shape(a, b) { } int area () { cout << "Rectangle class area :" <<endl; return (width * height); } }; class Triangle: public Shape{ public: Triangle( int a=0, int b=0):Shape(a, b) { } int area () { cout << "Triangle class area :" <<endl; return (width * height / 2); } };
  • 18.
    Polymorphism(conti) // Main functionfor the program int main( ) { Shape *shape; Rectangle rec(10,7); Triangle tri(10,5); // store the address of Rectangle shape = &rec; // call rectangle area. shape->area(); // store the address of Triangle shape = &tri; // call triangle area. shape->area(); return 0; }
  • 19.
  • 20.
    If this presentationhelped you, please visit our page facebook.com/baabtra and like it. Thanks in advance. www.baabtra.com | www.massbaab.com |www.baabte.com
  • 21.
    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 Start up Village Eranakulam, Kerala, India. Email: info@baabtra.com IKK Road, East Hill, Kozhikode Kerala, India. Ph: + 91 – 495 30 63 624 NIT-TBI, NIT Campus, Kozhikode, Kerala, India.