You are on page 1of 2

on

(c
ha
r
_n
Pe a
rs Object Oriented Programming m
on e[]
() Lab 10 ,ch
Pe int
Topic Covered: Inheritance ar
rs _a
de
on ge,
St
gr
(c ch
ud
ee
ha ar
en
[5
r _d
t
ch 0]
_n eg
ar do
a re
na ub
m
Pe e[]
m le
e[]
rs ,gp
e[
,on do
50 a
int ub
]_a le
int
ge _g
ag
) pa
evoi Figure: UML Diagram of inheritance
)
d voi
Ge d
t_ Ge
Da t_
Q1A. Create a class named Person. Da
ta(
) 1. It has two attribute as private ta(
voi )
d 2. name as character array of size 50. voi
Sh 3. age as int; d
ow Sh
4. Make no argument constructor to set name equals to empty stringow
_D
at
and age equals to zero. _D
e() 5. Make two argument constructor at
a()
6. The first argument changes the value of name.
7. The second argument changes the value of age.
8. Make void Get_Data() function to get name and age from user.
9. Make void Show_Data() function show the value of name and age
on screen.

Q1B. Create another class named Student that is publically inherited from
Person class.
1. It has two attribute as private
2. Degree as character array of size 50;
3. gpa as double data type.
4. Make no argument constructor to set degree equals to empty
string and gpa equals to 0.
5. Also call the no argument constructor of parent class.

1
6. Make four argument constructor
7. The first argument changes the value of name.
8. The second argument changes the value of age.
9. The third argument changes the value of degree.
10. The fourth argument changes the value of gpa.
11. To change name and age, call two argument constructor
of parent class.
12. Make void Get_Data() function to get value of name, age,
degree and gpa from user.
13. Also call Get_Data() function of parent class from child
class.
14. Make void Show_Data() function to show value of name, age,
degree and gpa on screen.
15. Also call Show_Data() function of parent class from child
class.

Q1C. Make main() function


Make a student object. Get and then show his/her information on
screen.

Here is the output of program

You might also like