fork(1) download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. class Cl {
  5. int a;
  6.  
  7. public:
  8. Cl():a(0){}
  9.  
  10. Cl& operator=(const Cl &c) {
  11. cout<<"==="<<endl;
  12. return *this;
  13. }
  14. Cl& operator=(const int &c) {
  15. cout<<"===1"<<endl;
  16. a=c;
  17. return *this;
  18. }
  19.  
  20. int& operator[](const int &c) {
  21. cout<<"[]"<<a<<endl;
  22. return a;
  23. }
  24.  
  25. };
  26.  
  27.  
  28. int main() {
  29. // your code goes here
  30.  
  31. Cl obj;
  32. obj = 2;
  33. obj[1];
  34. return 0;
  35. }
Success #stdin #stdout 0s 3296KB
stdin
Standard input is empty
stdout
===1
[]2