Computer Science, asked by ruplalsoren12345, 9 months ago

Write a program in C++ to show the concept of single inheritance.​

Answers

Answered by GeekyJS
0

Answer:

// inheritance.cpp #include <iostream> using namespace std; 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; } }; int main() { derive a; //object of derived class a.getdata(); a.readdata(); a.product(); return 0; } //end of program

Hope it's helpful to you.

Similar questions