-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy path15.cpp
48 lines (41 loc) · 969 Bytes
/
15.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
/*WAP to show one class students having data member roll no, name & age.
Inherits some features of teacher, when inherited public-ally.*/
#include<iostream>
#include<string>
using namespace std;
class teacher
{
public:
char sagar(char mohit)
{
cout << "\n\nEnter Teacher's Initials: ";
cin >> mohit;
cout << "Teacher's Initials: ";
cout << mohit;
}
};
class students: teacher
{
public:
string name;
int roll_no;
int age;
void displaydata(char mohit)
{
cout << "\nStudent Roll No.: "<< roll_no << "\nStudent Name: "<< name << "\nStudent Age: "<< age;
sagar(mohit);
}
};
int main()
{
char mohit;
students one;
cout<< "Enter Student Roll No.: ";
cin>> one.roll_no;
cout<< "Enter Student Name: ";
cin>> one.name;
cout<< "Enter Student Age: ";
cin>> one.age;
one.displaydata(mohit);
return 0;
}