Repository navigation
Expand file tree
/
Copy pathvirtual.cpp
More file actions
98 lines (79 loc) · 1.73 KB
/
Copy pathvirtual.cpp
File metadata and controls
98 lines (79 loc) · 1.73 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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
#include <iostream>
#include <string>
class Person
{
protected:
//std::string name;
unsigned char age;
public:
virtual void getdata(void);
virtual void putdata(void);
};
class Student : public Person
{
private:
unsigned int Mark[6];
int cur_id;
unsigned int Total;
public:
void putdata(void);
void getdata(void);
};
void Student::getdata(void)
{
unsigned char i;
Total = 0;
//std::cin >> name >> age;
for (i=0; i<6; i++)
{
std::cin >> Mark[i];
Total += Mark[i];
}
}
void Student::putdata(void)
{
//std::cout << name << " " << age << " " <<Total << " " << cur_id << std::endl;
}
class Professor : public Person
{
private:
int Publication;
int cur_id;
public:
void putdata(void);
void getdata(void);
};
void Professor::getdata(void)
{
//std::cin >> name >> age >> Publication;
}
void Professor::putdata(void)
{
//std::cout << name << " " << age << " " << Publication << " " << cur_id << std::endl;
}
int main(){
int n, val;
//std::cin>>n; //The number of objects that is going to be created.
Person *per[2];
per[0] = new Professor;
per[0]->getdata();
/*
for(int i = 0;i < n;i++)
{
std::cin>>val;
if(val == 1){
// If val is 1 current object is of type Professor
per[i] = new Professor;
per[i]->getdata();
}
else
{
per[i] = new Student; // Else the current object is of type Student
per[i]->getdata(); // Get the data from the user.
}
}
for(int i=0;i<n;i++)
per[i]->putdata(); // Print the required output for each object.
*/
return 0;
}