Answer to Question #241697 in C++ for James

Question #241697

Write a program to demonstrate the order of call of constructors and destructors in case of multiple inheritance where one or more base classes are virtual.


1
Expert's answer
2021-09-26T11:42:32-0400
#include <iostream>
using namespace std;

class A {
public:
  A() {
    cout << "A" << endl;
  }
};

class B {
public:
  B() {
    cout << "B" << endl;
  }
};

class C: public A, public B {
public:
  C() {
    cout << "C" << endl;
  }
}

int main() {
  C c;
  return 0
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

James
06.10.21, 10:55

Thanks a lot

Leave a comment

LATEST TUTORIALS
APPROVED BY CLIENTS