Home > Back-end >  Emergency C gagarin inheritance and derived
Emergency C gagarin inheritance and derived

Time:11-29

1
Write the following procedure run results, and draw the inheritance relationships between classes, to upload photos,

#include
using namespace std;

The class BASEA {

Public: BASEA () {cout & lt; <"This is BASEA class! \n"; }

};

The class BASEB {

Public: BASEB () {cout & lt; <"This is the BASEB class! \n"; }

};

The class DERIVEA: public BASEB, virtual public BASEA {

Public: DERIVEA () {cout & lt; <"This is DERIVEA class! \n"; }

};

The class DERIVEB: public BASEB, virtual public BASEA {

Public: DERIVEB () {cout & lt; <"This is DERIVEB class! \n"; }

};

The class TOPDERIV: public DERIVEA, virtual public DERIVEB {

Public: TOPDERIV () {cout & lt; <"This is TOPDERIV class! \n"; }

};

Int main ()

{

TOPDERIV topobj;

return 0;

}

CodePudding user response:

Want to know why the output is first BASEA because pure virtual function called constructor first?
  • Related