oop concept
TRANSCRIPT
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 23
2
3
Typing Speed
Jobs Applied
Week Company Designation Applied Date Current Status
1
2
3
OOP Concepts
Muhammed Ajmal [email protected] www.facebook.com/username twitter.com/username in.linkedin.com/in/profilename 9745020951
Overview
• Introduction
• Class
• Object
• Encapsulation
• Abstraction
• Inheritance
• Polymorphism
Introduction
• OOP is a design philosophy
• Stands for Object Oriented Programing
Object
• Any thing that really exist in the world
• a table, a car, a dog, a person, etc.
• It has some properties
• It has some action
class
• Classes provide the structure for objects
• It is a blue print
• It does not exist physically
Encapsulation
• The Wrapping of data and function into a
single unit
• It is also known as information-hiding
• It is the way of implementing abstraction
example
Class A
{
Int a;
Public int get()
{Return a;}
Public void set()
{a=10;}
}
Abstraction
• Data abstraction refers to, providing only essential
information to the user.
• Hide unnecessary data from the user.
class Bank
{
private int accno;
private String name;
private float Balance;
Abstraction contd.
private float Profit;
private float Loan;
public void display_to_clerk()
{
cout<<accountno<<Name<<Balnce)
}
Public void display()
{//display all }
}
Inheritance
• Mechanism of deriving a new class from an already
existing class.
• 5 types of inheritance
– Single level
– Multilevel
– Multiple Hierarchical
– Hybrid
Inheritance cont.
Inheritance contd.
Polymorphism
• `one name, multiple forms
Function Overloading
• Two or more function with same name but different function
• Differentiated by signature Class sample
{
Void add(int a,int b)
{
cout<<a+b;
}
Void add(int a,int b,int c)
{
cout<<a+b+c;}
}
Example contd.
Int main()
{
Sample s;
S.add(5,10);
S.add(5,10,15);
}
Output
15
30
Program using class class Student
{
public:
char Dob[15];
int marks[5];
int age;
int rollNo;
float avg;
char Name[19];
int total=0;
void setdata()
{
cout<<"\nRollNo: ";
cin>>rollNo;
cout<<"\n Name:";
cin>>Name;
cout<<"\nDOb";
cin>>Dob;
cout<<"Age";
cin>>age;
for(int i=0;i<5;i++) { cout<<"mark"<<i+1<<": "; cin>>marks[i]; total=total+marks[i]; cout<<"\n"; } avg=total/5.0; } void display() { cout<<" "<<rollNo<<" "<<Name<<" "<<age<<" "; cout<<total<<" "<<avg<<"\n"; }};
int main()
{
Student s[10];
int n;
cout<<"enter no.of student: ";
cin>>n;
for(int i=0;i<n;i++)
{
cout<<"\nenter details of student: "<<i+1;
s[i].setdata();
}
cout<<"\n********************************* \n\n";
cout<<"\nRollno Name Age Totalmark AverageMark\n";
for(int i=0;i<n;i++)
{
s[i].display();
}}
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: [email protected]
IKK Road, East Hill, Kozhikode Kerala, India. Ph: + 91 – 495 30 63 624
NIT-TBI, NIT Campus, Kozhikode, Kerala, India.
In C++
Int main()
{
Private:
Protected:
Public:
}
In java
Int main()
{
Default:
Private:
Protected:
Public:
}