Wisdom Materials
Home
About Us
Our Clients
Careers
Services
Education
Jobs
News
Business
Health
Astrology
Entertainment
RealEstate
Devotion
Contact Us
CPP Programs
/ CPP Program to Create Multilevel Inheritance
Program Name
Functions scope in CPP
Program Code
Copy Program
#include
class base { public: int x; void getdata() { cout << "Enter x value:"; cin >> x; } }; class derive1 : public base { public: int y; void readdata() { cout << "\nEnter y value:"; cin >> y; } }; class derive2 : public derive1 { private: int z; public: void indata() { cout << "\nEnter Z value= "; cin >> z; } void product() { cout << "\nProduct= " << x * y * z; } }; void main() { derive2 a; a.getdata(); a.readdata(); a.indata(); a.product(); }
Input
Enter x value: 1 Enter y value: 2 Enter z value: 3
Output
Product= 6
Home
Back