-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathclass48.cpp
61 lines (57 loc) · 999 Bytes
/
class48.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
#include<iostream> //program for creating class student store the roll no,class test stores the marks obtained in 2 subjects and class results
using namespace std;
class student
{
protected:
int rollno;
public:
void getno(int);
void putno();
};
void student::getno(int a)
{
rollno=a;
}
void student::putno()
{
cout<<"ROLL NO : "<<rollno<<endl;
}
class test:public student
{
protected:
float sub1,sub2;
public:
void getmarks(float ,float);
void putmarks();
};
void test::getmarks(float x,float y)
{
sub1=x;
sub2=y;
}
void test::putmarks()
{
cout<<"SUB 1 MARKS : "<<sub1<<endl;
cout<<"SUB 2 MARKS : "<<sub2<<endl;
}
class result:public test
{
float total;
public:
void display();
};
void result::display()
{
total=sub1+sub2;
putno();
putmarks();
cout<<"TOTAL : "<<total<<endl;
};
int main()
{
result student1;
student1.getno(999);
student1.getmarks(75,59);
student1.display();
return 0;
}