I have a simple class that has a pointer to a function. The constructor points it to the function "morning()" and I get the error message when compiling:
error: cannot convert ‘Test::morning’ from type ‘void (Test::)()’ to type ‘Test::function {aka void (*)()}’
     Test() {assignPtr = morning;}
The code does compile when the "morning()" and the typedef are declared outside the function and I can't figure out how to make it work within the current class.
#include <iostream>
#include <string>
class Test {
  public:
    Test() {assignPtr = morning;}
    void say(std::string a) {name = a; assignPtr();};
  private:
    typedef void(*function)();
    void morning() {std::cout << "Good morning, " << name << std::endl;}
    void night() {};
    function assignPtr;
    std::string name;
};
int main() {
    Test a;
    a.say("Miguel");
}
 
     
    