-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathlateBinding2.cpp
90 lines (84 loc) · 1.27 KB
/
lateBinding2.cpp
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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
#include <iostream>
#include <string>
using namespace std;
class Employee
{
protected:
int id,age,salary;
string name;
public:
Employee(int i, string n, int a, int s)
{
id = i;
name = n;
age = a;
salary = s;
}
virtual void clerk()=0;
void print_data()
{
cout << "Name: " << name << endl;
cout << "Age: " << age << endl;
cout << "Salary: " << salary << endl;
}
virtual ~Employee(){}
};
class ME : public Employee
{
public:
ME(int i, string n, int a, int s) : Employee(i,n,a,s){}
void clerk()
{
cout << "Dept: ME" << endl;
this->print_data();
}
~ME(){}
};
class CSE : public Employee
{
public:
CSE(int i, string n, int a, int s) : Employee(i,n,a,s){}
void clerk()
{
cout << "Dept: CSE" << endl;
this->print_data();
}
~CSE(){}
};
class ECE : public Employee
{
public:
ECE(int i, string n, int a, int s) : Employee(i,n,a,s){}
void clerk()
{
cout << "Dept: ECE" << endl;
this->print_data();
}
~ECE(){}
};
int main()
{
Employee *bptr;
int i,s,a;
string n;
cin >> i >> n >> a >> s;
switch(i)
{
case 1:
bptr = new CSE(i,n,a,s);
bptr->clerk();
break;
case 2:
bptr = new ECE(i,n,a,s);
bptr->clerk();
break;
case 3:
bptr = new ME(i,n,a,s);
bptr->clerk();
break;
default:
break;
}
delete bptr;
return 0;
}