fork download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. class Base
  5. {
  6. public:
  7. Base() {}
  8. virtual ~Base() {}
  9.  
  10. virtual void interfaceFunction1() = 0;
  11. private:
  12. Base(const Base&); // all derived classes should be uncopyable
  13. Base& operator=(const Base&);
  14.  
  15. // no data members
  16. };
  17.  
  18. struct Derived : Base
  19. {
  20. virtual void interfaceFunction1() {}
  21. };
  22.  
  23.  
  24. int main() {
  25. // your code goes here
  26. Derived d0, d1;
  27. //Derived d2(d0); // error: use of deleted function 'Derived::Derived(const Derived&)'
  28. d1 = d0; // error: use of deleted function 'Derived& Derived::operator=(const Derived&)'
  29. return 0;
  30. }
Compilation error #stdin compilation error #stdout 0s 3136KB
stdin
Standard input is empty
compilation info
prog.cpp: In function 'int main()':
prog.cpp:28:5: error: use of deleted function 'Derived& Derived::operator=(const Derived&)'
  d1 = d0;
     ^
prog.cpp:18:8: note: 'Derived& Derived::operator=(const Derived&)' is implicitly deleted because the default definition would be ill-formed:
 struct Derived : Base
        ^
prog.cpp:13:11: error: 'Base& Base::operator=(const Base&)' is private
     Base& operator=(const Base&);
           ^
prog.cpp:18:8: error: within this context
 struct Derived : Base
        ^
stdout
Standard output is empty