Search This Blog

Friday, 21 August 2020

Addition of inheritance

 #include<iostream>

#include<conio.h>

using namespace std;

class A                       //base class created 

{

int a;

public:                   //visibility mode public.

void getval_a();      //member function decleartion and getiing the valluse of a

int get_a();            //return value of a.

};

class B : public A              //derrived class from class a,

{

int b,c;                   //int tyoe data type

public:                    //visiblity mode public.

void getval_b();          //functio declaration

void add();            //addition of both the values

void display();          //disply the addition

};

void A::getval_a(int x)         //function define

{

a=x;                      //pass the value of a to x

}

int A::get_a()                //function define

{

return a;                 //return to the value of x to a.

}

void B::getval_b(int y)       //function define

{

b=y;                     //passa the vlue of b to the y.

}

void B::add()                //function define

{

c=get_a();              //store the value of a into the the a.

c=c+b;                  //addd c=a+b

}

void B::display()             //function define



No comments:

Post a Comment

Search This Blog

Contact Form

Name

Email *

Message *

Popular Posts