From e6f5d6b5318a6019d21af79fae6829897100cbc3 Mon Sep 17 00:00:00 2001 From: DEV TYAGI Date: Wed, 24 Oct 2018 16:41:56 +0530 Subject: [PATCH 1/2] inheritance --- inheritance1.cpp | 49 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) create mode 100644 inheritance1.cpp diff --git a/inheritance1.cpp b/inheritance1.cpp new file mode 100644 index 0000000..3cc3c1e --- /dev/null +++ b/inheritance1.cpp @@ -0,0 +1,49 @@ +//single level inheritance i.e taking one as a parent class and another as a child class +//Dtyagi-9 +#include +using namespace std; +class A +{ + +public: + int a,b; + A(){ + a=0; + b=0; + }; + A(int p,int q) + { + a=p; + b=q; + } + void getdata() + { + cout<<"enter the values in a and b \n"; + cin>>a>>b; + + } + + +}; + +class B:public A +{ +public: + +void display() +{ + cout<<"THE VALUES OF A AND B ARE: \n a="<>a>>b; + + } + + +}; +class C +{ +public: + int c; + void readdata() + { + cout<<"enter the value of c"; + cin>>c; + + } + C() + { + c=0; + } + + +}; +class B:public A,public C +{ +public: + +void display() +{ + cout<<"THE VALUES OF A ,B AND C ARE: \n a="<