I am working on a little project containing simple server which listens to messages.
Assuming we have the following classes:
class Message;
class Server
{
void handler1(Message msg);
void handler2(Message msg);
.
.
.
void handler19(Message msg);
};
Can i create a new function type of the class Server
that returns void
and gets a single Message
variable called msg like this:
typedef void(Server::*MessageHandler)(Message msg);
So the class declaration would be:
class Server
{
MessageHandler handler1;
.
.
.
MessageHandler handler19;
}
A thing as mentioned would come handy with sqlite3 callback functions (where the function declaration is not the cleanest).
If it is possible, how can i implement such function?
If this is not possible, is there any similar way of making the code more simple (like C# delegates)?
Thank you in advance!