Home > Back-end >  The destructor order of multiple inheritance and multiple inheritance
The destructor order of multiple inheritance and multiple inheritance

Time:10-13

Beginner's inheritance, confused by this, can you help to explain the

CodePudding user response:

That is a code you ah...

CodePudding user response:

The
1/f, beginners reference side reply:
that you are making code ah...
# include
using namespace std;

The class V1 {
Public:
V1 () {cout & lt; <"V1 constructor" & lt; ~ V1 () {cout & lt; <"V1 destructors" & lt;
};
The class V2 {
Public:
V2 () {cout & lt; <"V2 constructor" & lt; ~ V2 () {cout & lt; <"The destructor V2" & lt; };
The class A1: virtual public V1, public V2 {
Public:
A1 () {cout & lt; <"A1 constructor" & lt; ~ A1 () {cout & lt; <"Of" the destructor A1 & lt; };
The class A2: virtual public V1, public V2 {
Public:
A2 () {cout & lt; <"A2 constructor" & lt; ~ A2 () {cout & lt; <"Of" the destructor A2 & lt; };
Class B: virtual public A2, public A1 {
Public:

(B) {cout & lt; <"Constructor" B & lt; ~ (B) {cout & lt; <"The destructors" B & lt; The class A3: public V2 {
Public:
A3 () {cout & lt; <"A3 constructor" & lt; ~ A3 () {cout & lt; <"Of" the destructor A3 & lt; };

};
Void test () {
A, B;
//B: : A3 B;
}
Int main () {
The test ();
return 0; }

CodePudding user response:

The
1/f, beginners reference side reply:
that you are making code ah...
I think the picture will be able to understand
  • Related