-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy path25_student_data_inheritance.cpp
More file actions
62 lines (54 loc) · 1.16 KB
/
25_student_data_inheritance.cpp
File metadata and controls
62 lines (54 loc) · 1.16 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
#include <iostream>
using namespace std;
class student
{
private:
char name[30];
int age;
char gender;
public:
void getdata(void)
{
cout << "Enter the basic information of the student : " <<endl;
cout << "Name : ";
cin >> name;
cout << "Age: ";
cin >> age;
cout << "Gender : ";
cin >> gender;
}
void printdata(void)
{
cout << endl;
cout<< "Student Data" <<endl;
cout << endl;
cout << "Name : " << name << ", Age : " << age << ", Gender : " << gender <<endl;
}
};
class result: public student{
private:
int totalMarks;
char grade;
public:
void getResult(void)
{
cout << "Enter the student's result information : "<<endl;
cout<< "Total Marks : ";
cin >> totalMarks;
cout << "Grade : ";
cin >> grade;
}
void printResult(void)
{
cout << "Total Marks : " << totalMarks << ", Grade : " <<grade << endl;
}
};
int main() {
result std;
std.getdata();
std.getResult();
std.printdata();
std.printResult();
return 0;
}
//try the code at : https://repl.it/@Aravind1444/inheritancestudentdataincpp