-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathjay2.cpp
More file actions
51 lines (47 loc) · 958 Bytes
/
jay2.cpp
File metadata and controls
51 lines (47 loc) · 958 Bytes
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
48
49
50
51
#include<iostream>
using namespace std;
class teacher{
float salary;
public:
string name;
string dep;
string subject;
teacher(){
name="jaydev";
dep="btech";
subject ="math";
salary=55000;
}
teacher(string name,string dep,string subject){
this->name=name;
this->dep=dep;
}
teacher(teacher &obj){
name=obj.name;
}
void getInfo() {
cout<<"Name: "<<name<<endl<<"Dep: "<<dep<<endl<<"Subject: "<<subject<<endl;
}
void changeDep(string newDep){
dep=newDep;
}
void setSalary(float x){
salary=x;
}
float getSalary(){
return salary;
}
};
int main() {
teacher t1;
t1.name="jaydev";
t1.dep="btech";
t1.subject="oops";
// t1.salary=49;
// cout<<t1.salary<<" ";
t1.setSalary(23489);
// cout<<t1.getSalary()<<endl;
teacher t2(t1);
t1.getInfo();
return 0;
}