fork download
  1. #include<stdlib.h>
  2. #include <iostream> // cin, cout, instream, ostream, endl
  3.  
  4.  
  5. using namespace std;
  6.  
  7. class Rationnel
  8. {
  9. int *num,*den;
  10. public:
  11. Rationnel()
  12. {
  13. num=new int;
  14. den=new int;
  15. (*num)=0;
  16. (*den)=1;
  17. }
  18. Rationnel(int a,int b)
  19. {
  20. num=new int;
  21. den=new int;
  22. (*num)=a;
  23. (*den)=b;
  24. }
  25. Rationnel(Rationnel &R)
  26. {
  27. num=new int;
  28. den=new int;
  29. num=R.num;
  30. den=R.den;
  31. }
  32. ~Rationnel(void)
  33. {
  34. delete num;
  35. delete den;
  36. }
  37. int getnum()
  38. {
  39. return (*num);
  40. }
  41. int getden()
  42. {
  43. return (*den);
  44. }
  45. void setnum(int a)
  46. {
  47. (*num)=a;
  48. }
  49. void setden(int b)
  50. {
  51. (*den)=b;
  52. }
  53. float conversion()
  54. {
  55. return (1.0*(*num))/(*den);
  56. }
  57. /*friend Rationnel inversion()
  58.   {
  59.   Rationnel R;
  60.   int a;
  61.   //a=(*num);
  62.   R.setnum(getnum());
  63.   // a=(*den);
  64.   R.setden(getden());
  65.   return R;
  66.   }*/
  67. ostream &operator<<(ostream &out, const Rationnel &R) {
  68. return out << R.getnum()<< "/ " << R.getden();
  69. }
  70. instream &operator>>(ostream &in, const Rationnel &R) {
  71. int a
  72. in>>a;
  73. R.setnum(a);
  74. in>>a;
  75. R.setden(a);
  76. }
  77. };
  78. void read(Rationnel R)
  79. {
  80. int a;
  81. cout<<"numerateur :";
  82. cin>>a;
  83. R.setnum(a);
  84. cout<<"denominateur :";
  85. cin>>a;
  86. R.setden(a);
  87. }
  88. void print(Rationnel R)
  89. {
  90. cout<<R.getnum()<<"/"<<R.getden()<<endl;
  91. }
  92. Rationnel add(Rationnel R1,Rationnel R2)
  93. {
  94. Rationnel R3;
  95. R3.setnum(R1.getnum()*R2.getden()+R1.getden()*R2.getnum());
  96. R3.setden(R1.getden()*R2.getden());
  97. }
  98.  
  99. main()
  100. {
  101.  
  102. }
  103.  
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.cpp:67:67: error: 'std::ostream& Rationnel::operator<<(std::ostream&, const Rationnel&)' must take exactly one argument
               ostream &operator<<(ostream &out, const Rationnel &R) {
                                                                   ^
prog.cpp:70:15: error: 'instream' does not name a type
               instream &operator>>(ostream &in, const Rationnel &R) {
               ^
stdout
Standard output is empty