狠狠撸

狠狠撸Share a Scribd company logo
oop database doc for studevsgdy fdsyn hdf
INHERITANCE
? Inheritance:
? The capability of a class to derive properties and characteristics from another
class is called Inheritance
? .Inheritance is one of the most important features of Object-Oriented
Programming.
? Inheritance is a feature or a process in which, new classes are created from
the existing classes.
? The new class created is called “derived class” or “child class” and the existing
class is known as the “base class” or “parent class”. T
? Syntax:
class <derived_class_name> : <access-specifier> <base_class_name>
{
//body
}
? EXAMPLE:
#include<iostream>
using namespace std;
class Person
{
int id;
char name[100];
public:
void set_p();
void display_p();
};
void Person::set_p()
{
cout<<"Enter the Id:";
cin>>id;
cout<<"Enter the Name:";
cin>>name;
}
void Person::display_p()
{
cout<<endl<<"id: "<< id<<"nName: "<<name;
}
class Student: private Person
{
char course[50];
int fee;
public:
void set_s();
void display_s();
};
void Student::set_s()
{
set_p();
cout<<"Enter the Course Name:";
cin>>course;
cout<<"Enter the Course Fee:";
cin>>fee;
}
void Student::display_s()
{
display_p();
cout<<"nCourse: "<<course<<"nFee: "<<fee<<endl;
}
int main()
{
Student s;
s.set_s();
s.display_s();
return 0;
}
? Modes of Inheritance:
There are 3 modes of inheritance.
1. Public Mode: If we derive a subclass from a public base class. Then the
public member of the base class will become public in the derived class and
protected members of the base class will become protected in the derived
class.
2. Protected Mode: If we derive a subclass from a Protected base class. Then
both public members and protected members of the base class will become
protected in the derived class.
3. Private Mode: If we derive a subclass from a Private base class. Then both
public members and protected members of the base class will become Private
in the derived class.
Types Of Inheritance:-
1. Single inheritance
2. Multilevel inheritance
3. Multiple inheritance
4. Hierarchical inheritance
5. Hybrid inheritance
? Single Inheritance: In single inheritance, a class is allowed to inherit from
only one class. i.e. one subclass is inherited by one base class only.
? Syntax:
class subclass_name : access_mode base_class
{
// body of subclass
};
OR
class A
{
... .. ...
};
class B: public A
{
... .. ...
};
? Multiple Inheritance: Multiple Inheritance is a feature of C++ where a
class can inherit from more than one class. i.e one subclass is inherited from
more than one base class.
? Syntax:
class subclass_name : access_mode base_class1, access_mode base_class2,
....
{
// body of subclass
};
class B
{
... ..
};
class C
{
... .. ...
};
class A: public B, public C
{
... ... ...
};
? Multilevel Inheritance: In this type of inheritance, a derived class is created
from another derived class.
? Syntax:
class C
{
... .. ...
};
class B:public C
{
... .. ...
};
class A: public B
{
... ... ...
};
? Hierarchical Inheritance: In this type of inheritance, more than one
subclass is inherited from a single base class. i.e. more than one derived class
is created from a single base class.
? Syntax:-
class A
{
// body of the class A.
}
class B : public A
{
// body of class B.
}
class C : public A
{
// body of class C.
}
class D : public A
{
// body of class D.
}
. Hybrid (Virtual) Inheritance: Hybrid Inheritance is implemented by
combining more than one type of inheritance. For example: Combining Hierarchical
inheritance and Multiple Inheritance.
? Why we use inheritance?
We use inheritance in C++ when both the classes in the program have
the same logical domain and when we want the class to use the
properties of its superclass along with its properties.

More Related Content

Similar to oop database doc for studevsgdy fdsyn hdf (20)

inheritance
inheritanceinheritance
inheritance
Amir_Mukhtar
?
Inheritance in C++
Inheritance in C++Inheritance in C++
Inheritance in C++
RAJ KUMAR
?
Inheritance OOP Concept in C++.
Inheritance OOP Concept in C++.Inheritance OOP Concept in C++.
Inheritance OOP Concept in C++.
MASQ Technologies
?
11 Inheritance.ppt
11 Inheritance.ppt11 Inheritance.ppt
11 Inheritance.ppt
LadallaRajKumar
?
Inheritance in c++theory
Inheritance in c++theoryInheritance in c++theory
Inheritance in c++theory
ProfSonaliGholveDoif
?
inheriTANCE IN OBJECT ORIENTED PROGRAM.pptx
inheriTANCE IN OBJECT ORIENTED PROGRAM.pptxinheriTANCE IN OBJECT ORIENTED PROGRAM.pptx
inheriTANCE IN OBJECT ORIENTED PROGRAM.pptx
urvashipundir04
?
Inheritance
InheritanceInheritance
Inheritance
Pranali Chaudhari
?
Oopc (group 9)
Oopc (group 9)Oopc (group 9)
Oopc (group 9)
Xyber Prince
?
025466482929 -OOP with Java Development Kit.ppt
025466482929 -OOP with Java Development Kit.ppt025466482929 -OOP with Java Development Kit.ppt
025466482929 -OOP with Java Development Kit.ppt
DakshinaPahan
?
02-OOP with Java.ppt
02-OOP with Java.ppt02-OOP with Java.ppt
02-OOP with Java.ppt
EmanAsem4
?
OOP Assign No.03(AP).pdf
OOP Assign No.03(AP).pdfOOP Assign No.03(AP).pdf
OOP Assign No.03(AP).pdf
Anant240318
?
Java oops PPT
Java oops PPTJava oops PPT
Java oops PPT
kishu0005
?
E -COMMERCE.ppt
E -COMMERCE.pptE -COMMERCE.ppt
E -COMMERCE.ppt
classall
?
Opp concept in c++
Opp concept in c++Opp concept in c++
Opp concept in c++
SadiqullahGhani1
?
Inheritance.pptx
Inheritance.pptxInheritance.pptx
Inheritance.pptx
RutujaTandalwade
?
Inheritance
InheritanceInheritance
Inheritance
zindadili
?
Inheritance in c++
Inheritance in c++Inheritance in c++
Inheritance in c++
Vishal Patil
?
OOP C++
OOP C++OOP C++
OOP C++
Ahmed Farag
?
Inheritance
Inheritance Inheritance
Inheritance
Parthipan Parthi
?
OOP.ppt
OOP.pptOOP.ppt
OOP.ppt
Tanmay Dhatrak
?

Recently uploaded (20)

IDM Crack 2025 Internet Download Manger Patch
IDM Crack 2025 Internet Download Manger PatchIDM Crack 2025 Internet Download Manger Patch
IDM Crack 2025 Internet Download Manger Patch
wistrendugftr
?
HITRUST Overview and AI Assessments Webinar.pptx
HITRUST Overview and AI Assessments Webinar.pptxHITRUST Overview and AI Assessments Webinar.pptx
HITRUST Overview and AI Assessments Webinar.pptx
AmyPoblete3
?
IPv6 - Global and Malaysia's Perspectives
IPv6 - Global and Malaysia's PerspectivesIPv6 - Global and Malaysia's Perspectives
IPv6 - Global and Malaysia's Perspectives
APNIC
?
Elliptic Curve Cryptography Algorithm with Recurrent Neural Networks for Atta...
Elliptic Curve Cryptography Algorithm with Recurrent Neural Networks for Atta...Elliptic Curve Cryptography Algorithm with Recurrent Neural Networks for Atta...
Elliptic Curve Cryptography Algorithm with Recurrent Neural Networks for Atta...
IJCNCJournal
?
cyber hacking and cyber fraud by internet online money
cyber hacking and cyber fraud by internet online moneycyber hacking and cyber fraud by internet online money
cyber hacking and cyber fraud by internet online money
VEENAKSHI PATHAK
?
phase_4_presentation[1] - Read-Only.pptx Iot
phase_4_presentation[1]  -  Read-Only.pptx Iotphase_4_presentation[1]  -  Read-Only.pptx Iot
phase_4_presentation[1] - Read-Only.pptx Iot
harshithamandya49
?
2a Solving Equations Bar Method.pkdkdmptx
2a Solving Equations Bar Method.pkdkdmptx2a Solving Equations Bar Method.pkdkdmptx
2a Solving Equations Bar Method.pkdkdmptx
alvinlibre
?
AstuteAP: AI-Powered Supplier Invoice Automation for Seamless Accounts Payabl...
AstuteAP: AI-Powered Supplier Invoice Automation for Seamless Accounts Payabl...AstuteAP: AI-Powered Supplier Invoice Automation for Seamless Accounts Payabl...
AstuteAP: AI-Powered Supplier Invoice Automation for Seamless Accounts Payabl...
AstuteBusiness
?
办理卡普顿大学成绩单触购买加拿大颁叠鲍成绩单文凭定制
办理卡普顿大学成绩单触购买加拿大颁叠鲍成绩单文凭定制办理卡普顿大学成绩单触购买加拿大颁叠鲍成绩单文凭定制
办理卡普顿大学成绩单触购买加拿大颁叠鲍成绩单文凭定制
taqyed
?
Choking_Death_Statistics_2025_Presentation.pptx
Choking_Death_Statistics_2025_Presentation.pptxChoking_Death_Statistics_2025_Presentation.pptx
Choking_Death_Statistics_2025_Presentation.pptx
Joseph897315
?
KeepItOn-2024-Internet-Shutdowns-Annual-Report.pdf
KeepItOn-2024-Internet-Shutdowns-Annual-Report.pdfKeepItOn-2024-Internet-Shutdowns-Annual-Report.pdf
KeepItOn-2024-Internet-Shutdowns-Annual-Report.pdf
sabranghindi
?
Intelligent-Systems-in-Manufacturing.pptx
Intelligent-Systems-in-Manufacturing.pptxIntelligent-Systems-in-Manufacturing.pptx
Intelligent-Systems-in-Manufacturing.pptx
ErickWasonga2
?
Importance of understanding buyer behaviors.pptx
Importance of understanding buyer behaviors.pptxImportance of understanding buyer behaviors.pptx
Importance of understanding buyer behaviors.pptx
ankitregmi20580419
?
Antorik Q Final.pptx999999999999999999999
Antorik Q Final.pptx999999999999999999999Antorik Q Final.pptx999999999999999999999
Antorik Q Final.pptx999999999999999999999
PrayasChatterjee1
?
Advantages of Outsourcing IT Security Solutions
Advantages of Outsourcing IT Security SolutionsAdvantages of Outsourcing IT Security Solutions
Advantages of Outsourcing IT Security Solutions
Dalin Owen
?
加拿大毕业证购买(百年理工学院成绩单)颁颁文凭学历认证
加拿大毕业证购买(百年理工学院成绩单)颁颁文凭学历认证加拿大毕业证购买(百年理工学院成绩单)颁颁文凭学历认证
加拿大毕业证购买(百年理工学院成绩单)颁颁文凭学历认证
taqyed
?
The-Evolution-of-Media-Media and information literacy.pptx
The-Evolution-of-Media-Media and information literacy.pptxThe-Evolution-of-Media-Media and information literacy.pptx
The-Evolution-of-Media-Media and information literacy.pptx
febiemae2007
?
complete On-Page SEO Best Practices guide
complete On-Page SEO Best Practices guidecomplete On-Page SEO Best Practices guide
complete On-Page SEO Best Practices guide
Rana Hassan
?
加拿大毕业证(鲍罢惭成绩单)多伦多大学毕业证如何办理
加拿大毕业证(鲍罢惭成绩单)多伦多大学毕业证如何办理加拿大毕业证(鲍罢惭成绩单)多伦多大学毕业证如何办理
加拿大毕业证(鲍罢惭成绩单)多伦多大学毕业证如何办理
taqyed
?
Mastering FortiWeb: An Extensive Admin Guide for Secure Deployments
Mastering FortiWeb: An Extensive Admin Guide for Secure DeploymentsMastering FortiWeb: An Extensive Admin Guide for Secure Deployments
Mastering FortiWeb: An Extensive Admin Guide for Secure Deployments
Atakan ATAK
?
IDM Crack 2025 Internet Download Manger Patch
IDM Crack 2025 Internet Download Manger PatchIDM Crack 2025 Internet Download Manger Patch
IDM Crack 2025 Internet Download Manger Patch
wistrendugftr
?
HITRUST Overview and AI Assessments Webinar.pptx
HITRUST Overview and AI Assessments Webinar.pptxHITRUST Overview and AI Assessments Webinar.pptx
HITRUST Overview and AI Assessments Webinar.pptx
AmyPoblete3
?
IPv6 - Global and Malaysia's Perspectives
IPv6 - Global and Malaysia's PerspectivesIPv6 - Global and Malaysia's Perspectives
IPv6 - Global and Malaysia's Perspectives
APNIC
?
Elliptic Curve Cryptography Algorithm with Recurrent Neural Networks for Atta...
Elliptic Curve Cryptography Algorithm with Recurrent Neural Networks for Atta...Elliptic Curve Cryptography Algorithm with Recurrent Neural Networks for Atta...
Elliptic Curve Cryptography Algorithm with Recurrent Neural Networks for Atta...
IJCNCJournal
?
cyber hacking and cyber fraud by internet online money
cyber hacking and cyber fraud by internet online moneycyber hacking and cyber fraud by internet online money
cyber hacking and cyber fraud by internet online money
VEENAKSHI PATHAK
?
phase_4_presentation[1] - Read-Only.pptx Iot
phase_4_presentation[1]  -  Read-Only.pptx Iotphase_4_presentation[1]  -  Read-Only.pptx Iot
phase_4_presentation[1] - Read-Only.pptx Iot
harshithamandya49
?
2a Solving Equations Bar Method.pkdkdmptx
2a Solving Equations Bar Method.pkdkdmptx2a Solving Equations Bar Method.pkdkdmptx
2a Solving Equations Bar Method.pkdkdmptx
alvinlibre
?
AstuteAP: AI-Powered Supplier Invoice Automation for Seamless Accounts Payabl...
AstuteAP: AI-Powered Supplier Invoice Automation for Seamless Accounts Payabl...AstuteAP: AI-Powered Supplier Invoice Automation for Seamless Accounts Payabl...
AstuteAP: AI-Powered Supplier Invoice Automation for Seamless Accounts Payabl...
AstuteBusiness
?
办理卡普顿大学成绩单触购买加拿大颁叠鲍成绩单文凭定制
办理卡普顿大学成绩单触购买加拿大颁叠鲍成绩单文凭定制办理卡普顿大学成绩单触购买加拿大颁叠鲍成绩单文凭定制
办理卡普顿大学成绩单触购买加拿大颁叠鲍成绩单文凭定制
taqyed
?
Choking_Death_Statistics_2025_Presentation.pptx
Choking_Death_Statistics_2025_Presentation.pptxChoking_Death_Statistics_2025_Presentation.pptx
Choking_Death_Statistics_2025_Presentation.pptx
Joseph897315
?
KeepItOn-2024-Internet-Shutdowns-Annual-Report.pdf
KeepItOn-2024-Internet-Shutdowns-Annual-Report.pdfKeepItOn-2024-Internet-Shutdowns-Annual-Report.pdf
KeepItOn-2024-Internet-Shutdowns-Annual-Report.pdf
sabranghindi
?
Intelligent-Systems-in-Manufacturing.pptx
Intelligent-Systems-in-Manufacturing.pptxIntelligent-Systems-in-Manufacturing.pptx
Intelligent-Systems-in-Manufacturing.pptx
ErickWasonga2
?
Importance of understanding buyer behaviors.pptx
Importance of understanding buyer behaviors.pptxImportance of understanding buyer behaviors.pptx
Importance of understanding buyer behaviors.pptx
ankitregmi20580419
?
Antorik Q Final.pptx999999999999999999999
Antorik Q Final.pptx999999999999999999999Antorik Q Final.pptx999999999999999999999
Antorik Q Final.pptx999999999999999999999
PrayasChatterjee1
?
Advantages of Outsourcing IT Security Solutions
Advantages of Outsourcing IT Security SolutionsAdvantages of Outsourcing IT Security Solutions
Advantages of Outsourcing IT Security Solutions
Dalin Owen
?
加拿大毕业证购买(百年理工学院成绩单)颁颁文凭学历认证
加拿大毕业证购买(百年理工学院成绩单)颁颁文凭学历认证加拿大毕业证购买(百年理工学院成绩单)颁颁文凭学历认证
加拿大毕业证购买(百年理工学院成绩单)颁颁文凭学历认证
taqyed
?
The-Evolution-of-Media-Media and information literacy.pptx
The-Evolution-of-Media-Media and information literacy.pptxThe-Evolution-of-Media-Media and information literacy.pptx
The-Evolution-of-Media-Media and information literacy.pptx
febiemae2007
?
complete On-Page SEO Best Practices guide
complete On-Page SEO Best Practices guidecomplete On-Page SEO Best Practices guide
complete On-Page SEO Best Practices guide
Rana Hassan
?
加拿大毕业证(鲍罢惭成绩单)多伦多大学毕业证如何办理
加拿大毕业证(鲍罢惭成绩单)多伦多大学毕业证如何办理加拿大毕业证(鲍罢惭成绩单)多伦多大学毕业证如何办理
加拿大毕业证(鲍罢惭成绩单)多伦多大学毕业证如何办理
taqyed
?
Mastering FortiWeb: An Extensive Admin Guide for Secure Deployments
Mastering FortiWeb: An Extensive Admin Guide for Secure DeploymentsMastering FortiWeb: An Extensive Admin Guide for Secure Deployments
Mastering FortiWeb: An Extensive Admin Guide for Secure Deployments
Atakan ATAK
?

oop database doc for studevsgdy fdsyn hdf

  • 2. INHERITANCE ? Inheritance: ? The capability of a class to derive properties and characteristics from another class is called Inheritance ? .Inheritance is one of the most important features of Object-Oriented Programming. ? Inheritance is a feature or a process in which, new classes are created from the existing classes. ? The new class created is called “derived class” or “child class” and the existing class is known as the “base class” or “parent class”. T ? Syntax: class <derived_class_name> : <access-specifier> <base_class_name> { //body } ? EXAMPLE: #include<iostream> using namespace std; class Person { int id; char name[100]; public: void set_p(); void display_p(); }; void Person::set_p() {
  • 3. cout<<"Enter the Id:"; cin>>id; cout<<"Enter the Name:"; cin>>name; } void Person::display_p() { cout<<endl<<"id: "<< id<<"nName: "<<name; } class Student: private Person { char course[50]; int fee; public: void set_s(); void display_s(); }; void Student::set_s() { set_p(); cout<<"Enter the Course Name:"; cin>>course; cout<<"Enter the Course Fee:"; cin>>fee; }
  • 4. void Student::display_s() { display_p(); cout<<"nCourse: "<<course<<"nFee: "<<fee<<endl; } int main() { Student s; s.set_s(); s.display_s(); return 0; } ? Modes of Inheritance: There are 3 modes of inheritance. 1. Public Mode: If we derive a subclass from a public base class. Then the public member of the base class will become public in the derived class and protected members of the base class will become protected in the derived class. 2. Protected Mode: If we derive a subclass from a Protected base class. Then both public members and protected members of the base class will become protected in the derived class. 3. Private Mode: If we derive a subclass from a Private base class. Then both public members and protected members of the base class will become Private in the derived class. Types Of Inheritance:- 1. Single inheritance 2. Multilevel inheritance 3. Multiple inheritance 4. Hierarchical inheritance 5. Hybrid inheritance ? Single Inheritance: In single inheritance, a class is allowed to inherit from only one class. i.e. one subclass is inherited by one base class only.
  • 5. ? Syntax: class subclass_name : access_mode base_class { // body of subclass }; OR class A { ... .. ... }; class B: public A { ... .. ... }; ? Multiple Inheritance: Multiple Inheritance is a feature of C++ where a class can inherit from more than one class. i.e one subclass is inherited from more than one base class. ? Syntax: class subclass_name : access_mode base_class1, access_mode base_class2, .... { // body of subclass }; class B {
  • 6. ... .. }; class C { ... .. ... }; class A: public B, public C { ... ... ... }; ? Multilevel Inheritance: In this type of inheritance, a derived class is created from another derived class. ? Syntax: class C { ... .. ... }; class B:public C { ... .. ... }; class A: public B { ... ... ... }; ? Hierarchical Inheritance: In this type of inheritance, more than one subclass is inherited from a single base class. i.e. more than one derived class is created from a single base class.
  • 7. ? Syntax:- class A { // body of the class A. } class B : public A { // body of class B. } class C : public A { // body of class C. } class D : public A { // body of class D. } . Hybrid (Virtual) Inheritance: Hybrid Inheritance is implemented by combining more than one type of inheritance. For example: Combining Hierarchical inheritance and Multiple Inheritance. ? Why we use inheritance?
  • 8. We use inheritance in C++ when both the classes in the program have the same logical domain and when we want the class to use the properties of its superclass along with its properties.