fork download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. class Shape
  5. {
  6. public:
  7. virtual ~Shape() {}
  8.  
  9. virtual double getArea() const = 0;
  10. virtual double getPerimeter() const = 0;
  11. virtual void print() const = 0;
  12. };
  13.  
  14. bool sortByArea(Shape* first, Shape* second)
  15. {
  16. if(first == NULL || second == NULL)
  17. {
  18. return false;
  19. }
  20. return (first->getArea() < second->getArea());
  21. }
  22.  
  23. constexpr bool perimeterBiggerThan20(Shape* s)
  24. {
  25. if(!s)
  26. {
  27. return false;
  28. }
  29. return (s->getPerimeter() > 20);
  30. }
  31.  
  32. int main() {
  33. // your code goes here
  34. return 0;
  35. }
Compilation error #stdin compilation error #stdout 0s 15240KB
stdin
Standard input is empty
compilation info
prog.cpp: In function ‘constexpr bool perimeterBiggerThan20(Shape*)’:
prog.cpp:30:1: error: expression ‘Shape::getPerimeter’ is not a constant-expression
 }
 ^
stdout
Standard output is empty