dimanche 4 novembre 2018

Construct member function pointer from static function

I have a function in class A which accepts a function pointer of type int (ClassA::*f)(). I get an error while passing to it a static member function defined as such:

  class ClassA {
    public:
      static int getIntegerVal() {
        return 0;
      }
  }

If I try to pass ClassA::getIntegerVal, I get the following compilation error: candidate template ignored: could not match 'int (T::*)()' against 'int (*)()'

Why is a static member not considered a member of the class?

Aucun commentaire:

Enregistrer un commentaire