fork download
  1. #include<iostream>
  2. #include<fstream>
  3. using namespace std;
  4.  
  5. class Complex{
  6. private:
  7. double x;
  8. double y;
  9. public:
  10. Complex(double a,double b){
  11. x=a;
  12. y=b;
  13. }
  14.  
  15. void setx(double a){
  16. x=a;
  17. }
  18.  
  19. void sety(double b){
  20. y=b;
  21. }
  22.  
  23. double getx(){
  24. return x;
  25. }
  26.  
  27. double gety(){
  28. return y;
  29. }
  30. };
  31. istream& operator>>(istream& file1,Complex &c){
  32. double d,e;
  33. file1>>d>>e;
  34. cout << d << " -- " << e << endl;
  35. c.setx(d);
  36. c.sety(e);
  37. return file1;
  38. }
  39.  
  40.  
  41. int main(){
  42. Complex c1(1,2);
  43. Complex c2(1,2);
  44. char ch;
  45.  
  46. cin>>c1>>ch>>c2;
  47. return 0;
  48. }
Success #stdin #stdout 0s 3232KB
stdin
1 4 + 2 3
3 1 - 4 8
stdout
1 -- 4
2 -- 3