i have been working on a project and i need to know that is there anyway passing a function to template class? lets say i want this to perform sinus or cosinus function
#ifndef INTEGRAL_H
#define INTEGRAL_H
template<class F>
class Integral
{
public:
Integral( F func):f_(func){}
~Integral()=default;
Integral(){
int a,b,N;
double h=(b-a)/N;
sum=0.0;
for (size_t j=0; j<N;++j)
{
sum+=f_(a+j*h); // here i would like to perform sin(a+j*h) or cosinus or somethingelse
}
sum*=h;
}
double Sum(){return sum;}
private:
F f_;
double sum;
};
#endif // INTEGRAL_H