fork download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. class Test
  5. {
  6. public:
  7. Test()
  8. {
  9. cout << "default\n";
  10. }
  11.  
  12. private:
  13. Test(const Test&)
  14. {
  15. cout << "copy\n";
  16. }
  17.  
  18. Test& operator = (const Test&)
  19. {
  20. cout << "assign\n";
  21. return *this;
  22. }
  23. };
  24.  
  25. int main() {
  26. Test t = Test();
  27. }
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.cpp: In function ‘int main()’:
prog.cpp:13:2: error: ‘Test::Test(const Test&)’ is private
  Test(const Test&)
  ^
prog.cpp:26:16: error: within this context
  Test t = Test();
                ^
stdout
Standard output is empty