oop concept

21

Upload: baabtracom-first-coding-school-in-india

Post on 26-May-2015

206 views

Category:

Technology


0 download

TRANSCRIPT

Page 1: Oop concept
Page 2: Oop concept

Disclaimer: This presentation is prepared by trainees of baabtra as a part of mentoring program. This is not official document of baabtra –Mentoring PartnerBaabtra-Mentoring Partner is the mentoring division of baabte System Technologies Pvt . Ltd

Page 3: Oop concept

Week Target Achieved

1 30 20

2 30 22

3 30

Typing Speed

Page 4: Oop concept

OOP concepts

Yasir musthafa [email protected]/

yasirmusthafatwitter.com/yasirmusthafa ppin.linkedin.com/in/

yasirmusthafapp8891396749

Page 5: Oop concept

Introduction

• Purpose of c++ - To add object orientation to c programming

Page 6: Oop concept

The concepts

• Objects• Class• Abstraction• Encapsulation• Inheritance• Polymorphism

Page 7: Oop concept

objects

• Basic unit of oop concept• Both data and function are bundled as a unit

Page 8: Oop concept

Class

• Blue print of object• What an object consist of-• What operation can be performed-

Page 9: Oop concept

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

Page 10: Oop concept

Abstraction

• Mechanism of exposing only the interfaces and hiding the implementation details

Page 11: Oop concept

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 }

Page 12: Oop concept

Inheritance

• Code reusability• Process of forming a new class from an

existing class existing class-base class new class – derived class• is a - relationship

Page 13: Oop concept

Example // Base class class Shape { public: void setWidth(int w) { width = w; } void setHeight(int h) { height = h; } protected: int width; int height; };

Page 14: Oop concept

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; }

Page 15: Oop concept

Polymorphism

• Ability to use an operator or function in different ways

• Single function or an operator functioning in many ways different upon the usage

Page 16: Oop concept

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; } };

Page 17: Oop concept

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); } };

Page 18: Oop concept

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; }

Page 19: Oop concept

Thank you

Page 20: Oop concept

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

Page 21: Oop concept

Contact Us

Emarald Mall (Big Bazar Building)Mavoor Road, Kozhikode,Kerala, India.Ph: + 91 – 495 40 25 550

NC Complex, Near Bus StandMukkam, Kozhikode,Kerala, India.Ph: + 91 – 495 40 25 550

Start up VillageEranakulam,Kerala, India.

Email: [email protected]

IKK Road,East Hill, KozhikodeKerala, India.Ph: + 91 – 495 30 63 624

NIT-TBI,NIT Campus, Kozhikode,Kerala, India.