fork download
  1. #include <iostream>
  2.  
  3. using namespace std;
  4. struct C {
  5. //Obj() { cout << __func__<< endl; }
  6. //~Obj() { cout << __func__<< endl; }
  7. virtual ~C() { cout << __func__<< endl; } // Destructor
  8. C(const C&) = { cout << __func__<< endl; }; // Copy constructor
  9. C(C&&) = { cout << __func__<< endl; }; // Move constructor
  10. C& operator=(const C&) & = { cout << __func__<< endl; }; // Copy assignment operator
  11. C& operator=(C&&) & = { cout << __func__<< endl; }; // Move assignment operator
  12. };
  13. int main()
  14. {
  15. C obj1;
  16. C& obj2 = obj1;
  17.  
  18. return 0;
  19. }
  20.  
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.cpp:8:21: error: invalid pure specifier (only ‘= 0’ is allowed) before ‘cout’
     C(const C&) = { cout << __func__<< endl; };               // Copy constructor
                     ^~~~
prog.cpp:9:8: error: expected ‘)’ before ‘&&’ token
     C(C&&) = { cout << __func__<< endl; };                    // Move constructor
        ^~
prog.cpp:10:28: error: non-member function ‘C& operator=(const C&)’ cannot have ref-qualifier
     C& operator=(const C&) & = { cout << __func__<< endl; };  // Copy assignment operator
                            ^
prog.cpp:10:28: error: ‘C& operator=(const C&)’ must be a nonstatic member function
prog.cpp:10:34: error: invalid pure specifier (only ‘= 0’ is allowed) before ‘cout’
     C& operator=(const C&) & = { cout << __func__<< endl; };  // Copy assignment operator
                                  ^~~~
prog.cpp:10:59: error: expected declaration before ‘}’ token
     C& operator=(const C&) & = { cout << __func__<< endl; };  // Copy assignment operator
                                                           ^
stdout
Standard output is empty