What will be printed out as a result of the following code execution?
#include <iostream>
#include <string>

struct A {
  void exec() {
    std::cout << "Hello ";
  }
};

struct B {
  void exec() {}
};

struct C : virtual A, virtual B {
  void exec() {
    A::exec();
    std::cout << "World\n";
  }
};

int main() {
  A* a = new C();
  B* b = new C();
  C* c = new C();
  a->exec();
  b->exec();
  c->exec();
}

Follow CodeGalaxy

Mobile Beta

Get it on Google Play
Send Feedback
Cosmo
Sign Up Now
or Subscribe for future quizzes