We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
2 parents 5969e2a + dd4d064 commit 451d8d6Copy full SHA for 451d8d6
CPP/questions/BasicInheritance.cpp
@@ -0,0 +1,48 @@
1
+//private inheritance
2
+#include <iostream>
3
+using namespace std;
4
+class person
5
+{
6
+ int id;
7
+ string name;
8
+ public:
9
+ void set_p()
10
+ {
11
+ cout<<"Enter id\n";
12
+ cin>>id;
13
+ cout<<"Enter name\n";
14
+ cin>>name;
15
+ //cout<<name;
16
+ }
17
+ void display()
18
19
+ cout<<"Name is "<<name<<"\n";
20
+ cout<<"Id is "<<id<<"\n";
21
22
+};
23
+class Student:private person
24
25
+ string courseName;
26
+ int fee;
27
28
+ void get_s()
29
30
+ set_p();
31
+ cout<<"Enter Course Name\n";
32
+ cin>>courseName;
33
+ cout<<"Enter fee\n";
34
+ cin>>fee;
35
+
36
37
+ void S_display()
38
39
+ display();
40
+ cout<<courseName<<"\n"<<fee;
41
42
43
+int main()
44
45
+ Student s;
46
+ s.get_s();
47
+ s.S_display();
48
+}
0 commit comments