-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathInheritance_oops.cpp
More file actions
47 lines (38 loc) · 1.25 KB
/
Inheritance_oops.cpp
File metadata and controls
47 lines (38 loc) · 1.25 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
#include<iostream>
using namespace std;
//----------------------------INHERITANCE IN CPP------------------------------//
class university{
public: // parent class which contain all mendatory info about general sstudent of universty.
string departement;
int phon_no;
string address;
string name;
};
class inter_depmnt : public university{ // child class which inherit some property from parent.
public:
string subject;
int regNo;
int sub_taken;
inter_depmnt(string departement,int phon_no,string address,string subject,int regNo){
this->departement = departement; //constructore to intilize vaue.
this->phon_no = phon_no;
this->address = address;
this->subject = subject;
this->regNo = regNo;
}
};
void print(inter_depmnt s){
cout<<s.departement<<" "<<s.phon_no<<" "<<s.address<<" "<<s.subject<<" "<<s.regNo<<endl;
}
int main(){
// /* we can fill this menually and is well as by constructore.
inter_depmnt s1;
s1.departement = "english";
s1.phon_no = 98799890;
s1.address "xyz house no:42 ";
s1.regNo = 90;
// */
inter_depmnt s1("(english) ",034233232,"(xyz house no 89" ,"(english " ,99);// direct inetilization of values.
print(s1);//function to print val
return 0;
}