fork download
  1. #include <iostream>
  2.  
  3. class A {
  4. private:
  5. int *x;
  6. public:
  7. A() { x = new int; *(A::x) = 0; printme("A()"); }
  8. A(const int *y) { x = new int; *(A::x) = *y; printme("A(const int*)"); }
  9. ~A() { printme("~A()"); delete x; }
  10. void operator = (const int *y) { printme("before"); A(y); printme("after");}
  11.  
  12. void printme(const char* s) const
  13. { std::cout << s << ": " << this << ": " << *x << '\n'; }
  14. };
  15.  
  16. int main() {
  17. A a;
  18. int y = 3;
  19. a = &y;
  20. }
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.cpp: In member function ‘void A::operator=(const int*)’:
prog.cpp:10:60: error: declaration of ‘A y’ shadows a parameter
     void operator = (const int *y) { printme("before"); A(y); printme("after");}
                                                            ^
stdout
Standard output is empty