Circle.cpp 706 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. #include "Circle.h"
  2. #include <iostream>
  3. #include <fstream>
  4. //copy-constructor
  5. Circle::Circle(const Circle& other)
  6. {
  7. center = other.center;
  8. m_radius = other.m_radius;
  9. }
  10. Circle::~Circle()
  11. {
  12. //???
  13. }
  14. double Circle::Get_area()
  15. {
  16. return M_PI * m_radius * m_radius;
  17. }
  18. bool Circle::operator==(const Circle& other) const
  19. {
  20. if(center==other.center && m_radius == other.m_radius)
  21. {
  22. return true;
  23. }
  24. return false;
  25. }
  26. std::ostream& operator<<(std::ostream& os, const Circle& circle)
  27. {
  28. os << circle.center << " radius: " << circle.m_radius;
  29. return os;
  30. }
  31. Circle& operator>>(std::ifstream& is, Circle& circle)
  32. {
  33. char buff[20];
  34. is >> circle.center;
  35. is >>buff >> circle.m_radius;
  36. return circle;
  37. }