Header Ads Widget

Ticker

6/recent/ticker-posts

FINDING ADDITION IN SINGLE INHERITANCE PROGRAMING USING C++

 

"INHERITANCE PROGRAMING USING C++" , "Digitalise Data"

Find The Addition Of Two Number Using Inheritance Programing In C++


#include <iostream.h> 
#include <conio.h>
class base    //single base class
{
   public:
     int x;
   void getdata()
   {
     cout << "Enter the value of x = ";
     cin >> x;
   }
 };
class derive : public base    //single derived class
{
   private:
    int y;
   public:
   void readdata()
   {
     cout << "Enter the value of y = ";
     cin >> y;
   }
   void product()
   {
     cout << "Product = " << x * y;
   }
 };

void main()
 {
    derive a;     //object of derived class
    a.getdata();
    a.readdata();
    a.product();
    getch();
 }         //end of program


Thank You....!!!

Post a Comment

0 Comments