fork download
  1. struct Foo
  2. {
  3. int x, y;
  4.  
  5. Foo() = default;
  6. Foo(const Foo&) = delete;
  7. Foo& operator=(const Foo&) = delete;
  8. };
  9.  
  10. int main()
  11. {
  12. Foo f1 {1, 2};
  13. Foo f2 = {1, 2};
  14. }
  15.  
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.cpp: In function ‘int main()’:
prog.cpp:12:17: error: no matching function for call to ‘Foo::Foo(<brace-enclosed initializer list>)’
     Foo f1 {1, 2};
                 ^
prog.cpp:12:17: note: candidate is:
prog.cpp:5:5: note: Foo::Foo()
     Foo() = default;
     ^
prog.cpp:5:5: note:   candidate expects 0 arguments, 2 provided
prog.cpp:13:19: error: could not convert ‘{1, 2}’ from ‘<brace-enclosed initializer list>’ to ‘Foo’
     Foo f2 = {1, 2};
                   ^
stdout
Standard output is empty