-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPQ9.cpp
More file actions
80 lines (64 loc) · 1.19 KB
/
PQ9.cpp
File metadata and controls
80 lines (64 loc) · 1.19 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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
#include <bits/stdc++.h>
using namespace std;
class Person
{
public:
string name;
Person(string n)
{
name = n;
}
Person()
{
}
virtual void display()
{
cout << name << endl;
}
};
class Student : public Person
{
public:
string course;
int marks;
unsigned int year;
Student(string n, string c, int m, int y) : Person(n)
{
course = c;
marks = m;
year = y;
}
Student()
{
}
void display()
{
cout << name << " " << course << " " << marks << " " << year << endl;
}
};
class Employee : public Person
{
public:
string department;
long int salary;
Employee(string n, string d, long s) : Person(n)
{
department = d;
salary = s;
}
void display()
{
cout << name << " " << department << " " << salary << endl;
}
};
int main()
{
Person *obj1;
Student obj2("Shubham", "BSc_CS", 25, 1);
obj1 = &obj2;
obj1->display();
Employee obj3("Shubham", "Computer_Department", 100000);
obj1 = &obj3;
obj1->display();
return 0;
}