fork download
  1.  
  2. #include<iostream>
  3. using namespace std;
  4. class W3D{
  5. int x,y,z;
  6. public:
  7. W3D(int x=0, int y=0, int z=0) :x(x), y(y), z(z)
  8. {
  9. cout <<x;
  10. }
  11. W3D& operator= (W3D& w)
  12. {
  13. x=w.x; y=w.y; z=w.z; cout<<'='; return w;
  14. }
  15. W3D& operator +(W3D & t)
  16. {
  17. cout<<'+'; W3D suma(x+t.x, y+t.y, z+t.z);
  18. return suma;
  19. }
  20. };
  21.  
  22. int main()
  23. {
  24. W3D a0, a1(1), a2(2);//
  25. a0 = a2 = a0 + a1 + a2;
  26. }// kod daje wynik 012+1+3==
  27. // początek 012 wydaje mi się, że rozumiem. A dalej?
  28.  
  29.  
Success #stdin #stdout 0s 3140KB
stdin
Standard input is empty
stdout
012+1+3==