3. 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
4. Object Oriented Programming
Object-oriented programming (OOP) is a programming
paradigm that uses “Objects“ and their interactions to
design applications and computer programs.
5. Important in oops
• Object
• Class
• Data Abstraction
• Encapsulation
• Inheritance
• Polymorphism
6. Object
• Object is the basic unit of object-oriented programming.
• Objects are identified by its unique name.
• An object represents a particular instance of a class.
Example : Car is an object
7. •An Object is a collection of data members and associated
member functions also known as methods.
object
Data members
Model
Color
Start
Move
Stop
Methods
car
8. class
• Class is basically blue print for object.
• It declare and define what data variables the object will have
and what operations can be performed on the class’s object.
Class name
Data variable
Functions
Structure of class
9. #include <iostream.h>
class Square
{
private: int side, a;
public: int area( side)
{
a =side*side;
return a;
}
void show()
{
cout << "The area is::" << a;
}
};
void main()
{
Square x; //x is the object for class Square
x.area(10);
x.show();
}
The area is:: 100
10. Data abstraction
• Abstraction refers to showing only the essential features of the
application and hiding the details.
• Example : calculator
• Any C++ program where you implement a class with public
and private members is an example of data abstraction.
11. #include <iostream>
using namespace std;
class Adder{
public:
// constructor
Adder1(int i = 0)
{
total = i;
}
// interface to outside world
void addNum(int number)
{
total += number;
}
// interface to outside world
int getTotal()
{
return total;
};
private:
// hidden data from outside world
int total;
};
int main( )
{
Adder a;
a.addNum(10);
a.addNum(20);
a.addNum(30);
cout << "Total " << a.getTotal() <<endl;
return 0;
}
Out put
Total 60
12. Encapsulation
• Encapsulation is also known as Data Hiding.
• Encapsulation is the process of combining data and function
into a single unit called class.
class class name
{
private:
datatype data;
public:
Member functions;
};
main()
{
classname objectname1,objectname2……………;
}
13. Inheritance
• Inheritance is the process of forming a new class from an
existing class or base class.
• The base class is also known as parent class or super class.
• The new class that is formed is called derived class. Derived
class is also known as a child class or sub class.
15. Implementation of inheritance
class derived-class: access-specifier base-class
•Syntax for implementing derived class
•Access Control and Inheritance
Access public protected private
Same class yes yes yes
Derived classes yes yes no
Outside classes yes no no
16. Type of inheritance
• Single inheritance
In this this type of inheritance one derived class inherits
from only one base class.
B
A
17. • Multiple inheritance
In this type of inheritance a single derived class
may inherit from two or more base class.
BA
c
19. • Multi Level inheritance
In this type of inheritance the derived class inherits from
a class, which in turn inherits from other class.
B
C
A
20. • Hybrid (virtual) inheritance
it is the combination of hierarchical and multilevel
inheritance.
B
A
C
D
21. Polymorphism
• The word polymorphism means having many forms.
• C++ polymorphism means that a call to a member function
will cause a different function to be executed depending on the
type of object that invokes the function.
23. #include <iostream>
using namespace std;
class Polygon
{
protected:
int width, height;
public:
void set_values (int a, int b)
{
width=a; height=b;
}
};
class Rectangle: public Polygon {
public:
int area()
{ return width*height; }
};
int main () {
Rectangle rect;
Triangle trgl;
rect.set_values (4,5);
trgl.set_values (4,5);
cout << rect.area() << 'n';
cout << trgl.area() << 'n';
return 0;
}
class Triangle: public Polygon
{
public:
int area()
{
return width*height/2;
}
};
Out put
20
10
24.
25. 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?
Tired of spending huge amount of money to become a Software professional?
Do an online course
@ baabtra.com
We put industry standards to practice. Our structured, activity based courses are so designed
to make a quick, good software professional out of anybody who holds a passion for coding.
26. 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
Give a feedback @ massbaab.com/baabtra
Thanks in advance
www.baabtra.com | www.massbaab.com |www.baabte.com
27. 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
Contact Us