#include <iostream> using namespace std;struct foo{ int i; foo(int i): i(i) { cout << "int constructor, i = " << i << '\n'; } foo(const foo&f) = delete; void operator=(const foo&f) = delete; ~foo() {cout << "Destructor. i = " << i << '\n'; }}; int main(){ foo a(5); foo b= 6; foo c = foo(7);}
Standard input is empty
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
Standard output is empty
The brand new service which powers Ideone!
Widget for compiling and running the source code in a web browser!