0
A Daughter and a Son class inherit the Mother class. Each of the classes has print() which outputs the name as class member vari
1 Answer
+ 2
A Daughter and a Son class inherit the Mother class. Each of the classes has print() which outputs the name as class member variable. In the following user code
void callprint(Mother *p){
p->print();
}
int main(){
Daughter *d;
d = new Daughter (âJessicaâ);
Mother * m;
m= new Mother (âJasmineâ);
callPrint(m);
Son *s;
s = new Son (âJeffreyâ);
m = d;
callPrint(m);
s = m;
callPrint(m);
system(âpauseâ);
return 0;
}
What are the multiple flaws in the code? Cite them(Marks 7)
Rectify the code and use polymorphism of three Mother pointer variables to output the Mother, Daughter and Son names using callPrint()(Marks 8)