fork(14) download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. struct Copy {
  5.  
  6. Copy(int in) : _i(in) {}
  7. Copy& operator=(const Copy& copy) {
  8. _i = copy._i;
  9. std::cout << "I was Copied!\n";
  10. }
  11.  
  12. int _i;
  13. };
  14.  
  15. int main() {
  16.  
  17. Copy a(3), b(5), &c = b;
  18. a = c;
  19. std::cout << a._i << endl;
  20.  
  21. // your code goes here
  22. return 0;
  23. }
Success #stdin #stdout 0s 4356KB
stdin
Standard input is empty
stdout
I was Copied!
5