fork download
  1. namespace A{
  2. class B;
  3. }
  4.  
  5. A::B operator+(A::B a, A::B b);
  6.  
  7. namespace A{
  8. class B {
  9. private:
  10. int i;
  11. public:
  12. B() : i(0) {}
  13. B(int j) : i(j) {}
  14.  
  15. B friend ::operator+(B a, B b);
  16. };
  17. }
  18.  
  19. A::B operator+(A::B a, A::B b) {
  20. return A::B(a.i + b.i);
  21. }
  22.  
  23. int main() {
  24. A::B a(1), b(2);
  25. A::B c = a+b;
  26. return 0;
  27. }
Success #stdin #stdout 0s 15240KB
stdin
Standard input is empty
stdout
Standard output is empty