#include <stdio.h>
typedef double (*benchFunc)(double, double); // definition of function pointer
class SpectrogramData
{
public:
SpectrogramData(double (*b)(double, double), double rang1[2], double rang2[2])
{
m_pFunc = b;
rangeX1[0] = rang1[0]; rangeX1[1] = rang1[1];
rangeX2[0] = rang1[0]; rangeX2[1] = rang2[1];
}
virtual double value(double x, double y) const
{
const double result = m_pFunc(x,y);
return result;
}
private:
benchFunc m_pFunc; // function pointer
double rangeX1[2];
double rangeX2[2];
};
double testFunc(double d1, double d2)
{
return d1 + d2;
}
int main()
{
double rang1[2] = {1.1, 2.2};
double rang2[2] = {3.3, 4.4};
SpectrogramData sd(&testFunc, rang1, rang2);
double res = sd.value(1.1, 2.2);
printf("res: <%lf>\n", res);
return 0;
}
#include <stdio.h>
typedef double (*benchFunc)(double, double); // definition of function pointer
class SpectrogramData
{
public:
SpectrogramData(double (*b)(double, double), double rang1[2], double rang2[2])
{
m_pFunc = b;
rangeX1[0] = rang1[0]; rangeX1[1] = rang1[1];
rangeX2[0] = rang1[0]; rangeX2[1] = rang2[1];
}
virtual double value(double x, double y) const
{
const double result = m_pFunc(x,y);
return result;
}
private:
benchFunc m_pFunc; // function pointer
double rangeX1[2];
double rangeX2[2];
};
double testFunc(double d1, double d2)
{
return d1 + d2;
}
int main()
{
double rang1[2] = {1.1, 2.2};
double rang2[2] = {3.3, 4.4};
SpectrogramData sd(&testFunc, rang1, rang2);
double res = sd.value(1.1, 2.2);
printf("res: <%lf>\n", res);
return 0;
}
To copy to clipboard, switch view to plain text mode
Bookmarks