-
Notifications
You must be signed in to change notification settings - Fork 0
/
SingleInheritance2.cpp
49 lines (45 loc) · 1.12 KB
/
SingleInheritance2.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
/**
*
* using Protected access specifier to asscess the instant member of Parant class
*
**/
#include<iostream>
using namespace std;
class Student
{
protected:
char name[30];
int age;
char gender[5];
int totalnumberOfFaculties;
int totalnumberOfCourses;
};
class ComputerScience:public Student
{
public:
void getdata()
{
cout<<"Enter Your Name : ";
cin>>name;
cout<<"Enter Your Age : ";
cin>>age;
cout<<"Enter Your Gender : ";
cin>>gender;
cout<<"Enter the Total Number of Faculties : ";
cin>>totalnumberOfFaculties;
cout<<"Enter the Total Number of Courses : ";
cin>>totalnumberOfCourses;
}
void view()
{
cout<<"Name : "<<name<<"\nAge : "<<age<<"\nGender : "<<gender<<endl;
cout<<"Total Number of Faculties : "<<totalnumberOfFaculties<<"\nTotal Number of Courses : "<<totalnumberOfCourses<<endl;
}
};
int main()
{
ComputerScience stud;
stud.getdata();
stud.view();
return 0;
}