fork download
  1. #include <cmath>
  2. #include <iostream>
  3. using namespace std;
  4. class Sphere
  5. {
  6. double r;
  7. public:
  8. double V() const { return (4/3) * 3.14 * pow(r,3); }
  9. bool equal(const Sphere& s) const
  10. {
  11. cout << V() << " == " << s.V() << " : " << ( V() == s.V() );
  12. return ( V() == s.V() );
  13.  
  14. }
  15.  
  16. explicit Sphere(double rr = 1): r(rr){}
  17.  
  18. };
  19. main()
  20. {
  21. Sphere s(3);
  22. s.equal(s);
  23. }
Success #stdin #stdout 0s 3340KB
stdin
Standard input is empty
stdout
84.78 == 84.78 : 1