#include <iostream>
#include <math.h>

class Function { 
   private:
      float (*function)(float);
   public:
      Function(float method(float)) : function(method) {}
      float eval(float x) {
         return function(x);
      }
      float derive(float x, float error = 0.001) {
         return (function(x) - function(x + error)) / error;
      }
      float integrate(float x0, float x1, float partitions = 100) {
         float integral = 0;
         float step = (x1 - x0) / partitions;
         for(float i = 0; i < partitions; i += step) integral += step * function(i);
         return integral;
      }
};


float exampleFunction(float x) {
   return 2 * pow(x, 2) + 5;
}


int main() {
   Function myFunction (exampleFunction);
   std::cout << myFunction.eval(6) << std::endl;
}
