Class A {
Public:
Void f () {
Cout<& lt;" A: : f ().. "& lt;
};
Class B {
Public:
Void f () {
Cout<& lt;" B: : f ().. "& lt;
Void g () {
Cout<& lt;" B: : g ().. "& lt;
};
Class C: public A, public B {
Public:
Void g () {
Cout<& lt;" C: : g ().. "& lt;
Void h () {
Cout<& lt;" C: : h ().. "& lt;
}
};
Int main () {
C obj.
Obj. F ();//statements 2
Obj. A: : f ();//statement 3
Obj. B: : f ();//statement 4
Obj. G ();//statement 5
system("pause");
return 0;
}
The compiler generates a wrong statement ()
A statement which 1 B, 2 C statement which 3 D 4 E statement 5
Answer: A, B
Why is A, B?
CodePudding user response:
Multiple inheritance,,
CodePudding user response:
Is the exam? Under the multiple inheritance mode ambiguity... Must start with a virtual base class to define...CodePudding user response:
1. 2 sentences for multiple inheritance repeat for error of a... When used to indicate the class object belongs... Ex: A: : f (); A or B: : f ();class A {
Public:
Void f () {
Cout & lt; <"A: : f ().. "& lt;}
};
Class B {
Public:
Void f () {
Cout & lt; <"B: : f ().. "& lt;}
Void g () {
Cout & lt; <"B: : g ().. "& lt;}
};
Class C: public A, public B {
Public:
Void g () {
Cout & lt; <"C: : g ().. "& lt;}
Void h () {
Cout & lt; <"C: : h ().. "& lt;A: : f ();//statements 1
}
};
Int main () {
C obj.
Obj. B: : f ();//statements 2
Obj. A: : f ();//statement 3
Obj. B: : f ();//statement 4
Obj. G ();//statement 5
system("pause");
return 0;
}