Open navigation menu
Close suggestions
Search
Search
en
Change Language
Upload
Sign in
Sign in
Download free for days
0 ratings
0% found this document useful (0 votes)
11 views
5 pages
Inheritance 1
Uploaded by
sathiya
AI-enhanced title
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content,
claim it here
.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
Download
Save
Save Inheritance1 For Later
Share
0%
0% found this document useful, undefined
0%
, undefined
Print
Embed
Report
0 ratings
0% found this document useful (0 votes)
11 views
5 pages
Inheritance 1
Uploaded by
sathiya
AI-enhanced title
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content,
claim it here
.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
Carousel Previous
Carousel Next
Download
Save
Save Inheritance1 For Later
Share
0%
0% found this document useful, undefined
0%
, undefined
Print
Embed
Report
Download
Save Inheritance1 For Later
You are on page 1
/ 5
Search
Fullscreen
Single Level Inheritance
#include<iostream> class marks : public student
{
using namespace std; private:
class student int m1,m2,m3;
{ public:
void getmarks()
protected: { // getdata();
int rno; cout<<"Enter Marks 1 :- \t";
char name[20]; cin>>m1;
cout<<"Enter Marks 2 :- \t";
public: cin>>m2;
void getdata() cout<<"Enter Marks 2 :- \t";
{ cin>>m3; }
void display()
cout<<"Enter RollNo :- \t";
{ cout<<rno<<"\t"<<name<<"\
cin>>rno; t"<<m1<<"\t"<<m2<<"\t"<<m3; }
cout<<"Enter Name :- \t"; };
cin>>name; main(){ marks std; std.getdata();
std.getmarks(); std.display();
SATHIYA
} RR
Multiple Inheritance
#include<iostream.h> class statement:public student,public sports
using namespace std; {
int tot,avg;
class student
public:
{ protected: int rno,m1,m2;
void display()
public: {
void get(){ tot=(m1+m2+sm);
cout<<"Enter the Roll no :"; avg=tot/3;
cin>>rno; cout<<"\n\n\tRoll No : <rno<<"\n\tTotal: <<tot;
cout<<"Enter the two marks :"; cout<<"\n\tAverage : "<<avg;
cin>>m1>>m2; }}; }
class sports };
main()
{ protected:
{
int sm; // sm = Sports mark
statement obj;
public: void getsm() { obj.get();
cout<<"\nEnter the sports mark :"; obj.getsm();
cin>>sm; }}; obj.display();
SATHIYA RR
}
Hierarchical Inheritance
#include<iostream> class Triangle: public Shape
{
using namespace std;
public:
class Shape float area ()
{ {
protected: return (width * height / 2);
float width, height; }
public: };
void set_data (float a, float b)
main ()
{ width = a; {
height = b; Rectangle rect;
} Triangle tri;
}; rect.set_data (5,3);
class Rectangle: public Shape tri.set_data (2,5);
cout << rect.area() << endl;
{
cout << tri.area() << endl;
public:
float area () }
{ return (width * height);
}
}; SATHIYA RR
Multilevel Inheritance
#include<iostream> void student:: display()
{ cout <<"Roll NO:"<<rl<<endl;
#include<bits/stdc++.h>
cout<<"name : "<<nm<<endl; }
using namespace std; void marks ::getmarks()
class student // base class { cout<<"enter three subject marks "<<endl;
{ cin>>s1>>s2>>s3; }
protected: int rl; char nm[20]; void marks ::putmarks()
public: void read(); void display(); }; { cout <<"subject 1:"<<s1<<endl;
cout<<" subject 2 : "<<s2<<endl;
class marks : public student
cout <<"subject 3:"<<s3<<endl; }
{ void result::process()
protected: int s1, s2, s3; {t= s1+s2+s3;
public: p = t/3.0;
void getmarks(); void putmarks(); }; p>=60?strcpy(div,"first"):p>=50?strcpy(div, "second"):
class result : public marks strcpy(div,"third");
}
{
void result::printresult()
private: int t; float p; char div[10]; {cout<<"total = "<<t<<endl;
public: void process(); void printresult(); }; cout<<"per = "<<p<<endl;
void student::read() { cout<<"div = "<<div<<endl; }
cout<<"enter Roll no and Name "<<endl; main()
cin>>rl>>nm; } { result x; x.read(); x.getmarks(); x.process();
SATHIYA RR
x.display(); x.putmarks(); x.printresult(); }
Hybrid Inheritance
#include<iostream> class negative
using namespace std; {protected:
class arithmetic int n1,n2,diff;
{protected: public:
int num1, num2; void sub()
public: {cout<<"\nFor Subtraction:";
void getdata() cout<<"\nEnter the first number: ";
{cout<<"For Addition:"; cin>>n1;
cout<<"\nEnter the first number: "; cout<<"\nEnter the second number: ";
cin>>num1; cin>>n2;
cout<<"\nEnter the second number: "; diff=n1-n2; } };
cin>>num2; }}; class result:public positive, public negative
class positive:public arithmetic {public:
{protected: void display(){
int sum; cout<<"\nSum of "<<num1<<" and "<<num2<<"=
public: "<<sum;
void add() cout<<"\nDifference of "<<n1<<" and "<<n2<<"=
{getdata(); "<<diff;} };
sum=num1+num2; } }; main(){result z;z.add();z.sub();z.display();}
SATHIYA RR
You might also like
International A Level FURTHER MATHEMATICS With Mechanics
PDF
100% (2)
International A Level FURTHER MATHEMATICS With Mechanics
482 pages
Westfalia Basic Training 1
PDF
100% (4)
Westfalia Basic Training 1
68 pages
Computer Science
PDF
No ratings yet
Computer Science
34 pages
Single Inheritance
PDF
No ratings yet
Single Inheritance
7 pages
Hierachical, Multiple, Multileve, Hybrid Inheritance
PDF
No ratings yet
Hierachical, Multiple, Multileve, Hybrid Inheritance
10 pages
24bsit018 A4
PDF
No ratings yet
24bsit018 A4
37 pages
Inheritance Program
PDF
No ratings yet
Inheritance Program
18 pages
Wa0045.
PDF
No ratings yet
Wa0045.
47 pages
C++ Inheritance
PDF
No ratings yet
C++ Inheritance
47 pages
Inheritance Program
PDF
No ratings yet
Inheritance Program
7 pages
Inheritance: by Prof. Manikandan Dept of Computer Application QMC, Chennai
PDF
100% (1)
Inheritance: by Prof. Manikandan Dept of Computer Application QMC, Chennai
31 pages
Inhert
PDF
No ratings yet
Inhert
8 pages
Inheritance in Object Oriented Programming
PDF
No ratings yet
Inheritance in Object Oriented Programming
90 pages
S1 Programs
PDF
No ratings yet
S1 Programs
31 pages
C
PDF
No ratings yet
C
217 pages
Module 6 - Inheritance
PDF
No ratings yet
Module 6 - Inheritance
30 pages
100 - Soham - Assignment 4
PDF
No ratings yet
100 - Soham - Assignment 4
11 pages
National Institute of Technology Kurukshetra: Apse Lab
PDF
No ratings yet
National Institute of Technology Kurukshetra: Apse Lab
31 pages
INHERITANCE
PDF
No ratings yet
INHERITANCE
13 pages
Experiment 11 - Inheritance, Virtual Classes and Virtual Functions
PDF
No ratings yet
Experiment 11 - Inheritance, Virtual Classes and Virtual Functions
23 pages
Inheritance
PDF
No ratings yet
Inheritance
6 pages
CPP Unit-V
PDF
No ratings yet
CPP Unit-V
26 pages
Inheritance
PDF
No ratings yet
Inheritance
16 pages
Inheritance: Agnel Institute of Technology & Design
PDF
No ratings yet
Inheritance: Agnel Institute of Technology & Design
7 pages
Practical Related Questions.: SR - No:05
PDF
No ratings yet
Practical Related Questions.: SR - No:05
5 pages
Multilevel Inheritance
PDF
No ratings yet
Multilevel Inheritance
2 pages
Oop Practical 4 Inheritance
PDF
No ratings yet
Oop Practical 4 Inheritance
11 pages
Inheritance
PDF
No ratings yet
Inheritance
16 pages
CH 5
PDF
No ratings yet
CH 5
45 pages
Answer Cae2 Oop
PDF
No ratings yet
Answer Cae2 Oop
54 pages
Programs OOP-Inheritance Using CPP Unit 2
PDF
No ratings yet
Programs OOP-Inheritance Using CPP Unit 2
12 pages
Unit3 Week1 OODP
PDF
No ratings yet
Unit3 Week1 OODP
24 pages
Unit 4
PDF
No ratings yet
Unit 4
11 pages
Write A C Program To Implement The Multilevel In...
PDF
No ratings yet
Write A C Program To Implement The Multilevel In...
4 pages
Oop Lab Full Programs
PDF
No ratings yet
Oop Lab Full Programs
93 pages
Inheritence
PDF
No ratings yet
Inheritence
56 pages
Inheritance
PDF
No ratings yet
Inheritance
15 pages
Oops Lab ECE: 38.WAP To Implement Use of Multiple Inheritance
PDF
No ratings yet
Oops Lab ECE: 38.WAP To Implement Use of Multiple Inheritance
31 pages
Department of Computer Engineering: Exercise
PDF
No ratings yet
Department of Computer Engineering: Exercise
15 pages
C++ Coding
PDF
No ratings yet
C++ Coding
15 pages
Lab 05
PDF
No ratings yet
Lab 05
12 pages
Multilevel Inheritance
PDF
No ratings yet
Multilevel Inheritance
5 pages
Oop Inher Assignent 4
PDF
No ratings yet
Oop Inher Assignent 4
21 pages
Types of Inheritance
PDF
No ratings yet
Types of Inheritance
12 pages
Syed Shams Haider 203 Lab Report 08
PDF
No ratings yet
Syed Shams Haider 203 Lab Report 08
34 pages
Oodp W6
PDF
No ratings yet
Oodp W6
6 pages
OODP Unit 3
PDF
No ratings yet
OODP Unit 3
22 pages
Inheritance
PDF
No ratings yet
Inheritance
57 pages
C++ Chapter5
PDF
No ratings yet
C++ Chapter5
20 pages
A Simple Example of Inheritance.: Using Class Int Public Void Int Int
PDF
No ratings yet
A Simple Example of Inheritance.: Using Class Int Public Void Int Int
3 pages
Program For Inheritence With C++: #Include Using Namespace #Include #Include Class Protected Char Int Char Public
PDF
No ratings yet
Program For Inheritence With C++: #Include Using Namespace #Include #Include Class Protected Char Int Char Public
24 pages
Forms of Inheritance
PDF
No ratings yet
Forms of Inheritance
10 pages
Record 1
PDF
No ratings yet
Record 1
49 pages
Assignment No.03
PDF
No ratings yet
Assignment No.03
15 pages
OOMP Lab - Manual 2021 by Ajay Wadekar
PDF
No ratings yet
OOMP Lab - Manual 2021 by Ajay Wadekar
26 pages
Worker
PDF
No ratings yet
Worker
36 pages
Function Overloading
PDF
No ratings yet
Function Overloading
48 pages
Opps
PDF
No ratings yet
Opps
33 pages
C ++ All Programs
PDF
No ratings yet
C ++ All Programs
13 pages
Inheritance Prog
PDF
No ratings yet
Inheritance Prog
16 pages
Computer Engineering Laboratory Solution Primer
From Everand
Computer Engineering Laboratory Solution Primer
Karan Bhandari
No ratings yet
Oracle Certified Professional Java Programmer OCPJP 1Z0 809
From Everand
Oracle Certified Professional Java Programmer OCPJP 1Z0 809
Manish Soni
No ratings yet
Groupby and Having
PDF
No ratings yet
Groupby and Having
2 pages
Chapter1 Intro
PDF
No ratings yet
Chapter1 Intro
13 pages
Attributes
PDF
No ratings yet
Attributes
3 pages
8 Thsem
PDF
No ratings yet
8 Thsem
32 pages
Worksheet 3 - Kinematics Equations
PDF
No ratings yet
Worksheet 3 - Kinematics Equations
2 pages
) برای اعتباسنجیlong2015
PDF
No ratings yet
) برای اعتباسنجیlong2015
30 pages
Classical Mechanics and Special Theory of Relativity - 01
PDF
No ratings yet
Classical Mechanics and Special Theory of Relativity - 01
4 pages
Simple Harmonic Motion
PDF
No ratings yet
Simple Harmonic Motion
21 pages
365 Daily Workout Maths P3 Answers
PDF
No ratings yet
365 Daily Workout Maths P3 Answers
204 pages
High Altitude Student Platform (HASP) 2021 Final Report
PDF
No ratings yet
High Altitude Student Platform (HASP) 2021 Final Report
33 pages
Next Roll Prediction
PDF
33% (3)
Next Roll Prediction
77 pages
Chapter 4 Vector Space
PDF
No ratings yet
Chapter 4 Vector Space
66 pages
Composite Wall Experiment
PDF
No ratings yet
Composite Wall Experiment
6 pages
Ceiling Diffusers (Halton)
PDF
No ratings yet
Ceiling Diffusers (Halton)
7 pages
General Physics Assignment
PDF
No ratings yet
General Physics Assignment
14 pages
Maternal Pelvis
PDF
100% (2)
Maternal Pelvis
32 pages
Vishay 601-1045
PDF
No ratings yet
Vishay 601-1045
2 pages
51 Ls at 400 Kpa
PDF
No ratings yet
51 Ls at 400 Kpa
1 page
Nexus Charge Amplifier
PDF
No ratings yet
Nexus Charge Amplifier
16 pages
Omar Khayyam Biography: Presented by Fajar Syahadi (0403201001)
PDF
No ratings yet
Omar Khayyam Biography: Presented by Fajar Syahadi (0403201001)
14 pages
Gui
PDF
No ratings yet
Gui
516 pages
Journals Price List For 2022: No. Title Journal Abbreviation Issn (Print) Issn (E-Only)
PDF
No ratings yet
Journals Price List For 2022: No. Title Journal Abbreviation Issn (Print) Issn (E-Only)
24 pages
National 5 Maths Memory List
PDF
No ratings yet
National 5 Maths Memory List
2 pages
Principle of Concrete Mix Design
PDF
No ratings yet
Principle of Concrete Mix Design
3 pages
Datos de Chumaceras INA Rodamientos
PDF
No ratings yet
Datos de Chumaceras INA Rodamientos
10 pages
Srm-3006: Selective Radiation Meter For Electromagnetic Fields Up To 6 GHZ
PDF
No ratings yet
Srm-3006: Selective Radiation Meter For Electromagnetic Fields Up To 6 GHZ
24 pages
Chapter 4 Part-1 Sawyer's Book
PDF
No ratings yet
Chapter 4 Part-1 Sawyer's Book
11 pages
PCM To PWM Analysis Brief
PDF
No ratings yet
PCM To PWM Analysis Brief
15 pages
Lesson 39 - Transcript. Build Applications With Glide - Part 2
PDF
No ratings yet
Lesson 39 - Transcript. Build Applications With Glide - Part 2
112 pages
Automobile Engineering Experiment 10: Study of Camber, Caster, Toe-In or Toe-Out Camber
PDF
No ratings yet
Automobile Engineering Experiment 10: Study of Camber, Caster, Toe-In or Toe-Out Camber
4 pages
Cyclone Design
PDF
100% (2)
Cyclone Design
11 pages