fork download
  1. #include <iostream>
  2. #include <iomanip>
  3.  
  4. using namespace std;
  5.  
  6. class Test {
  7. public:
  8. Test() { cout << "Test()" << endl; }
  9. Test(int x):val_(x){ cout << "Test(" << x << ")" << endl; }
  10. Test(const Test& t):val_(t.val_) { cout << "Test(const Test& " << t.val_ << ")" << endl; }
  11. Test& operator = (const Test& t) {
  12. cout << "Test& operator = (const Test& " << t.val_ <<")" << endl;
  13. val_ = t.val_;
  14. return *this;}
  15. ~Test() { cout << "~Test()" << endl; }
  16. int val() const { return val_; }
  17. private:
  18. int val_ = 0;
  19. };
  20.  
  21. int main(int argc, const char * argv[])
  22. {
  23. Test t = t;
  24. cout << t.val() << endl;
  25. }
  26.  
Success #stdin #stdout 0s 3468KB
stdin
Standard input is empty
stdout
Test(const Test& 134515346)
134515346
~Test()