-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpracticep48_inheritance_1.cpp
More file actions
51 lines (47 loc) · 996 Bytes
/
practicep48_inheritance_1.cpp
File metadata and controls
51 lines (47 loc) · 996 Bytes
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
#include <iostream>
#include <string>
using namespace std;
//inheritance, access modes and specifiers for classes
class Student{
private:
int roll_no;
protected:
char section[10];
public:
string name;
void get_rollno(){
cout << "Enter roll number: ";
cin >> roll_no;
};
void show_rollno(){
cout << "Roll number: " << roll_no << endl;
}
};
class Result: public Student{
private:
float fees;
public:
void get_data(){
get_rollno();
cout << "Enter fees: ";
cin >> fees;
cout << "Enter Section: ";
cin >> section;
};
void display(){
show_rollno();
cout<<"Name: "<<name<<endl;
cout << "Fees: " << fees << endl;
cout << "Section: " << section << endl;
}
};
int main(){
Result r;
cout<<"Enter name: ";
getline(cin,r.name);
r.get_data();
cout<<endl;
cout<<"Student Details"<<endl;
r.display();
return 0;
}