Home > Back-end >  Consult everybody, seems to be checked the didn't get the result
Consult everybody, seems to be checked the didn't get the result

Time:03-07

See A problem on the teaching material, it should call in the class A constructor parameter, but the final output is A constructor with no parameters, hope bosses the sprout new explain to me, thank you ~
#include
using namespace std;
Class A {
Public:
A (int x) {cout<& lt;" A constructor: "& lt; (A) {cout<& lt;" A constructor "& lt;
};

Class B: virtual public A {
Public:
B (int x, int y) : A (x) {cout
};

Class c: virtual public A {
Public:
C (int x, int y) : A (x) {cout<& lt;" C constructor: "& lt; };

Class D: public c, public B {
Public:
D (int x, int y, int z, int w) : B (x, y), c (x, z) {cout<& lt;" D constructor: "& lt; };

Int main () {
D obj (1, 2, 3, 4);
}
  • Related