0

I've just read up about pointers, so wanted to see if I can try and use them in my program.

I have the function "equation", which at present is t^2. I also have the function "gauss", in which I am going to use the equation t^2, (code for this is not written yet). I was hoping to be able to use a pointer so that if I change the function "equation" to t^3 + t + 1 for example, I wont need to change the code for "gauss".

Could someone please tell me if this is the correct set up? Not sure if gauss should be defined within "double equation (double t)" or separately as I have done below?

Thanks in advance!

```
#include <iostream>
#include <vector>
#include <cmath>
#include <iomanip>
using namespace std;
typedef double(*fun)(double);
//Declare functions
double gauss(fun f, double a, double b, int n);
double equation(double t);
//=============================================================================================
int main()
{
gauss(equation,a,b,n);
return 0;
}
//============================================================================================
double gauss(fun f, double a, double b, int n)
{
}
//=============================================================================================
double equation (double t)
{
return t*t;
}
```

*Edited
by sexyzebra19*: n/a