fork download
  1. class Derived;
  2.  
  3. class Base
  4. {
  5. public:
  6. Base() = default;
  7.  
  8. Base(const Derived &d) = delete;
  9. Base& operator=(const Derived& other) = delete;
  10. };
  11.  
  12. class Derived : public Base
  13. {
  14. };
  15.  
  16. int main()
  17. {
  18. Derived d;
  19. Base b = d;
  20. }
  21.  
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.cpp: In function ‘int main()’:
prog.cpp:19:14: error: use of deleted function ‘Base::Base(const Derived&)’
     Base b = d;
              ^
prog.cpp:8:5: error: declared here
     Base(const Derived &d) = delete;
     ^
stdout
Standard output is empty