Advertisement
achulkov2

Untitled

Jan 26th, 2018
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.46 KB | None | 0 0
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. const int PI = 3.1415926535;
  5.  
  6.  
  7. class Figure {
  8. public:
  9. virtual double Area() const = 0;
  10. };
  11.  
  12. class Square : public Figure {
  13. private:
  14. double a;
  15. public:
  16. Square(double a): a(a) {}
  17. double Area() const {
  18. return a * a;
  19. }
  20. };
  21.  
  22. class Circle : public Figure {
  23. private:
  24. double r;
  25. public:
  26. Circle(double r): r(r) {}
  27. double Area() const {
  28. return PI * r * r;
  29. }
  30. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement