-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathteacherclass.cpp
More file actions
57 lines (56 loc) · 1.09 KB
/
Copy pathteacherclass.cpp
File metadata and controls
57 lines (56 loc) · 1.09 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
48
49
50
51
52
53
54
55
56
57
// create a class that defines the teacher's name, salary, department, subject;
#include <iostream>
using namespace std;
class Teacher
{
private:
string name;
string department;
string subject;
double salary;
public:
void setName(string n)
{
name = n;
}
string getName()
{
return name;
}
void setDept(string d)
{
department = d;
}
string getDept()
{
return department;
}
void setSub(string sub)
{
subject = sub;
}
string getSub()
{
return subject;
}
void setSalary(double s)
{
salary = s;
}
double getSalary()
{
return salary;
}
};
int main()
{
Teacher t1;
t1.setName("xyz");
cout << "Teacher name: " << t1.getName() << endl;
t1.setSalary(25000);
cout << "salary: " << t1.getSalary() << endl;
t1.setDept("Computer Science");
cout << "Department is: " << t1.getDept() << endl;
t1.setSub("C++");
cout << "Subject name is: " << t1.getSub() << endl;
}