fork download
  1. #include <iostream>
  2.  
  3. struct A
  4. {
  5. A() = delete;
  6. A(int x)
  7. : x(x)
  8. {
  9. }
  10. virtual ~A() = 0;
  11. int x;
  12. };
  13. A::~A() = default;
  14.  
  15. struct B : virtual A
  16. {
  17. B()
  18. //: A(-1)
  19. {
  20. }
  21. virtual ~B() = 0;
  22. };
  23. B::~B() = default;
  24.  
  25. struct C : B
  26. {
  27. C()
  28. : A(7)
  29. , B()
  30. {
  31. }
  32. };
  33.  
  34. int main()
  35. {
  36. C c;
  37. std::cout << c.x << std::endl;
  38. }
  39.  
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.cpp: In constructor ‘B::B()’:
prog.cpp:19:2: error: use of deleted function ‘A::A()’
  {
  ^
prog.cpp:5:2: error: declared here
  A() = delete;
  ^
stdout
Standard output is empty