Hello,

I tried already different variations of statements for the function parameter, but I still do not have the right version of it. I have got a function pointer and want to pass it as function parameter. Please tell me what is the right usage of it?

Qt Code:
  1. class SpectrogramData: public QwtRasterData
  2. {
  3. public:
  4. SpectrogramData(double (*b)(double, double), double rang1[2], double rang2[2]):
  5. QwtRasterData(QwtDoubleRect(rang1[0], rang2[0], rang1[1]- rang1[0], rang2[1]- rang2[0]))
  6. {
  7. benchFunc = b;
  8. rangeX1[0] = rang1[0]; rangeX1[1] = rang1[1];
  9. rangeX2[0] = rang1[0]; rangeX2[1] = rang2[1];
  10. }
  11.  
  12. virtual QwtRasterData *copy() const
  13. {
  14. return new SpectrogramData( benchFunc , &rangeX1[2], &rangeX2[2]); //<<< << this is the reason for the error
  15. }
  16.  
  17. virtual QwtDoubleInterval range() const
  18. {
  19. return QwtDoubleInterval(0.0, 10.0);
  20. }
  21.  
  22. virtual double value(double x, double y) const
  23. {
  24.  
  25. const double result = benchFunc(x,y);
  26. return result;
  27. }
  28.  
  29. private:
  30. double (*benchFunc)(double, double); // function pointer
  31. double rangeX1[2];
  32. double rangeX2[2];
  33. };
To copy to clipboard, switch view to plain text mode 

error:
Compiling ./qt/plot.cpp
plot.cpp: In constructor 'SimpleData::SimpleData(double, double, double)':
plot.cpp:60: warning: passing 'double' for argument 1 to 'int abs(int)'
plot.cpp: In member function 'virtual QwtRasterData* SpectrogramData::copy() const':
plot.cpp:109: error: no matching function for call to 'SpectrogramData::SpectrogramData(double (* const*)(double, double), const double*, const double*)'
plot.cpp:99: note: candidates are: SpectrogramData::SpectrogramData(double (*)(double, double), double*, double*)
plot.cpp:97: note: SpectrogramData::SpectrogramData(const SpectrogramData&)
make[1]: *** [../obj/linux-amd64-gcc-lsb31/plot.o] Error 1
make: *** [obj_qt] Error 2