fork download
  1. #include <iostream>
  2.  
  3. using namespace std;
  4. struct foo
  5. {
  6. int i;
  7. foo(int i): i(i) { cout << "int constructor, i = " << i << '\n'; }
  8. foo(const foo&f) = delete;
  9. void operator=(const foo&f) = delete;
  10. ~foo() {cout << "Destructor. i = " << i << '\n'; }
  11. };
  12.  
  13.  
  14. int main()
  15. {
  16. foo a(5);
  17. foo b= 6;
  18. foo c = foo(7);
  19. }
  20.  
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.cpp: In function ‘int main()’:
prog.cpp:17:10: error: use of deleted function ‘foo::foo(const foo&)’
prog.cpp:8:3: error: declared here
prog.cpp:18:16: error: use of deleted function ‘foo::foo(const foo&)’
prog.cpp:8:3: error: declared here
stdout
Standard output is empty