From a42f778ca816162f310c771c68570d330d4e783a Mon Sep 17 00:00:00 2001 From: Kiranmai1106 <71929885+Kiranmai1106@users.noreply.github.com> Date: Sat, 3 Oct 2020 19:45:00 +0530 Subject: [PATCH] Create Multilevel.cpp --- Multilevel.cpp | 44 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100644 Multilevel.cpp diff --git a/Multilevel.cpp b/Multilevel.cpp new file mode 100644 index 0000000..b975fda --- /dev/null +++ b/Multilevel.cpp @@ -0,0 +1,44 @@ + +#include +using namespace std; +class base //single base class +{ + public: + int x; + void getdata() + { + cout << "Enter value of x= "; cin >> x; + } +}; +class derive1 : public base // derived class from base class +{ + public: + int y; + void readdata() + { + cout << "\nEnter value of y= "; cin >> y; + } +}; +class derive2 : public derive1 +{ + private: + int z; + public: + void indata() + { + cout << "\nEnter value of z= "; cin >> z; + } + void product() + { + cout << "\nProduct= " << x * y * z; + } +}; +int main() +{ + derive2 a; + a.getdata(); + a.readdata(); + a.indata(); + a.product(); + return 0; +}