Having this class :
class Automat
{
private:
// some members ...
public:
Automat();
~Automat();
void addQ(string& newQ) ;
void addCharacter(char& newChar) ;
void addLamda(Lamda& newLamda) ;
void setStartSituation(string& startQ) ;
void addAccQ(string& newQ) ;
bool checkWord(string& wordToCheck) ;
friend istream& operator >> (istream &isInput, Automat &newAutomat);
string& getSituation(string& startSituation) ;
};
And also class called Menu which has the follow method :
void Menu::handleStringSituations(string &stringOfSituation , Automat* autoToHandle ,void (Automat::*methodToDo) () )
{
// some code ...
(*autoToHandle).*methodToDo() ;
}
The line (*autoToHandle).*methodToDo() ; gives an error .
As you can see I trying to pass any method from Automat class as a parameter to handleStringSituations method with no success.
What you try to do is usually known as closure, a concept strong in functional programming. Rather than reinventing the wheel, I suggest you look into Boost::Phoenix, which provides this in a nice, peer reviewed library.
http://www.boost.org/doc/libs/1_47_0/libs/phoenix/doc/html/index.html
However, since C++ is a statically typed language, you will have to do some marshalling. There is no such thing like a generic function (object) in C++.