Advertisement
Guest User

Untitled

a guest
Nov 20th, 2019
134
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.82 KB | None | 0 0
  1. // ConsoleApplication38.cpp : Этот файл содержит функцию "main". Здесь начинается и заканчивается выполнение программы.
  2. //
  3.  
  4. #include <iostream>
  5. using namespace std;
  6. class Point
  7. {
  8. protected:
  9. double x, y;
  10. public:
  11. Point()
  12. {
  13. x = y = 0;
  14. }
  15. Point(double x, double y)
  16. {
  17. this->x = x;
  18. this->y = y;
  19. }
  20. };
  21. class Cirlce:public Point
  22. {
  23. private:
  24. double r;
  25. public:
  26. Cirlce() :Point()
  27. {
  28. r = 0;
  29. }
  30. Cirlce(double x, double y, double r) :Point(x,y)
  31. {
  32. this->r = r;
  33. }
  34. friend ostream& operator<<(ostream& out, Cirlce& circle)
  35. {
  36. out << "Center = [" << circle.x <<";"<< circle.y<<"];" << "Radius ="<<circle.r << endl;
  37. return out;
  38. }
  39. };
  40. int main()
  41. {
  42. Cirlce circle(2, 3, 4);
  43. cout << circle;
  44. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement