I need answers with details for following questions 4) Lets look at a code examp
ID: 3662805 • Letter: I
Question
I need answers with details for following questions
4) Lets look at a code example for inheritance.
class Base {
//private methods
void printMyType() {
cout << "this is base type" << endl;
}
//public methods
void printAllInfo() {
cout << "this An accout" << endl;
printMyType();
}
}; //end base class
class derived : public Base {
//private method
void printMyType() {
cout << "this is derived type" << endl;
}
//public methods
void printAllInfo() {
mobileAccount::PrintAccountInfo();
printMyType();
}
}; //end derived class
How would you instantiate an instance of the derive class, and call its base and derived methods ?
5) What is a superclass ?
What is the subclass ?
Explanation / Answer
4.How would you instantiate an instance of the derive class, and call its base and derived methods ?
main(){
derived d;
d.printAllInfo();
d.Base::printAllInfo();
}
for calling private functions are methods are not accesible other than within class .
if u want access private function by using virtual keyword and friend function from derived class instance
5.What is a superclass ?
What is the subclass ?
ans:we know that in object oriented language classes inherited/derived from other classes called has inheritance.
The derived class called as subclass.he class from which it's derived is called the superclass.
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.