Skip to content

Commit 07f5342

Browse files
Inheritance Practice
1 parent 5b5ffad commit 07f5342

File tree

1 file changed

+54
-0
lines changed

1 file changed

+54
-0
lines changed

Inheritence.cpp

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
#include<iostream>
2+
#include "Class.cpp"
3+
#define sp " "
4+
#define endl "\n"
5+
using namespace std;
6+
7+
class Inheritence : private Demo{
8+
9+
private:
10+
int id;
11+
protected:
12+
const string s {"Rahul"};
13+
public:
14+
Inheritence(int a, int b, int id) : Demo(a, b) {
15+
this->id = id;
16+
}
17+
18+
void getValue(){
19+
// Demo::getNumbers();
20+
cout<<"From Base Class : "<<y<<sp<<z<<endl;
21+
cout<<id<<endl;
22+
cout<<this->getString()<<endl;
23+
}
24+
25+
string getString(){
26+
return this->s;
27+
}
28+
const static void output(){
29+
cout<<"Program coded by Rahul Bordoloi."<<endl;
30+
}
31+
};
32+
33+
int extern classNumber;
34+
35+
int main()
36+
{
37+
/*
38+
Demo obj;
39+
obj.displayCount();
40+
Demo obj2, obj3;
41+
obj.getNumbers();
42+
obj.output("Rahul");
43+
// obj3.output("Bordoloi");
44+
obj3.displayCount();
45+
*/
46+
47+
Inheritence obj(7,8,9);
48+
obj.getValue();
49+
Demo::output("Hehehehahahaohoho");
50+
cout<<classNumber<<endl;
51+
Inheritence::output();
52+
return 0;
53+
54+
}

0 commit comments

Comments
 (0)