forked from codebloded/BackToBasics.cpp
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvirtualBaseClass.cpp
More file actions
77 lines (66 loc) · 1.52 KB
/
virtualBaseClass.cpp
File metadata and controls
77 lines (66 loc) · 1.52 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
#include<iostream>
using namespace std;
class Student{
protected:
int rollNo;
public:
void set_rollNo(int r)
{
rollNo = r;
}
void printRoll(void)
{
cout<<"Student Roll No."<<rollNo<<endl;
}
};
class Test : virtual public Student{
protected:
float python;
float web;
float cpp;
public:
void set_marks(float p, float w , float c)
{
python =p;
web = w;
cpp = c;
}
void print_marks(void){
cout<<"The marks in Python is: "<<python<<endl;
cout<<"The marks in web development is: "<<web<<endl;
cout<<"The marks in C++ Programming is: "<<cpp<<endl;
}
};
class Traning : virtual public Student{
protected:
int traningStars;
public:
void setStars(int st){
traningStars = st;
}
void print_Stars(void){
cout<<"The Traning Stars of student is: "<<traningStars<<endl;
}
};
class Result : public Test, public Traning{
protected:
float total;
public:
void display(void)
{
total = python + cpp + web + traningStars;
printRoll();
print_marks();
print_Stars();
cout<<"The Result is: "<<total<<endl;
}
};
int main()
{
Result rohan;
rohan.set_rollNo(2);
rohan.set_marks(54.7 , 67.9, 90.0);
rohan.setStars(4);
rohan.display();
return 0;
}