I get a segmentation fault in my program when calling a function
"TestFn" that has been passed as a pointer into another function.
The following excerpt should give enough information as to what I am
doing wrong...
typedef void TIdxMultiFunc (int i, std::vector<double> f);
void TestFn(int i, std::vector<double> f)
{
double t; // execution does not get this far
...
f[0] = t*t;
f[1] = t*t*t;
}
void TestSolve(std::vector<double> &a)
{
....
TIdxMultiFunc *ptr = &TestFn;
afn(y, ptr, 2);
}
void afn(std::vector<double> &y, TIdxMultiFunc *f, int n)
{
....
int i;
std::vector<double> bf;
bf.resize(ndata - 1);
for (i = 0; i < n; i++)
{
f(i, bf); // segmentation fault occurs here