fork download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. struct A {
  5. public:
  6. int y;
  7. explicit A() {}
  8. explicit A(int x) { y = x; }
  9. };
  10.  
  11. struct B : public virtual A {
  12. using A::A;
  13. };
  14.  
  15. int main(int argc, char** argv) {
  16. B b(5);
  17. cout << b.y << endl;
  18. return 0;
  19. }
Success #stdin #stdout 0s 3344KB
stdin
Standard input is empty
stdout
5