0% found this document useful (0 votes)
8 views2 pages

Single Inheritance

Uploaded by

saadkhan73212
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
8 views2 pages

Single Inheritance

Uploaded by

saadkhan73212
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

channel link : h ps://www.youtube.

com/c/ComputerScienceAcademy7
h ps://youtu.be/0fKQhG3hqZ4

#include<iostream.h>
#include<conio.h>

// 1. Single inheritance

class number //base class


{
protected:
int a;
public:
void getdata(int x)
{
a = x;
}

void display()
{
cout<<"Number = "<<a<<endl;

}
};

class square : public number


{
private:
int sq;
public:
void getsquare()
{
sq = a * a;

void displaysq()
{
cout<<"Square = "<<sq<<endl;

}
};
void main()
{
clrscr();

square s;
s.getdata(25);
s.display();
s.getsquare();
s.displaysq();

getch();

You might also like