Hello,
I need to use pointer to members and retrieve the value (a double) that these members should return. But I have a compile error:
Qt Code:
  1. #include <vector>
  2. class B {
  3. double _mean, _mean2;
  4. enum { cnt = 2 };
  5. public:
  6. double (B::*fptr[cnt])(void) const;
  7. B() {
  8. fptr[0] = &B::getMean;
  9. fptr[1] = &B::getMean2;
  10. }
  11. double getMean() const { return _mean; }
  12. double getMean2() const { return _mean2; }
  13. };
  14.  
  15. class A {
  16. public:
  17. std::vector<B> _vec;
  18.  
  19. };
  20. //main.cpp
  21. B objB;
  22. A objA;
  23. double db = objA._vec.at(0).fptr[0]; //here error; doens't B::mean() return a double?
To copy to clipboard, switch view to plain text mode 
Qt Code:
  1. //error:
  2. error C2440: 'initializing' : cannot convert from 'double (__thiscall B::* )(void) const' to 'double'
To copy to clipboard, switch view to plain text mode 
Maybe i', using it in a wrong way.....how can I do this thing, please?