fork download
  1. #include <iosfwd>
  2.  
  3. struct Fraction
  4. {
  5. int numerator;
  6. int denominator;
  7. };
  8.  
  9. std::ostream& operator<<(std::ostream&, const Fraction&);
  10.  
  11.  
  12.  
  13. #include <iostream>
  14.  
  15. std::ostream& operator<<(std::ostream& os, const Fraction & f)
  16. {
  17. return os << f.numerator << " / " << f.denominator ;
  18. }
  19.  
  20.  
  21.  
  22. int main()
  23. {
  24. std::cout << Fraction{ 5, 9} << '\n' ;
  25. }
Success #stdin #stdout 0s 3340KB
stdin
Standard input is empty
stdout
5 / 9