I'm coding a server and I've set up a TCP connection with all the clients. Now, when a Client sends a packet I check the opcode of the packet so I can process it.
At the moment, I have an OpcodeHandler struct that currently contains String name
but I also want it to have a C++-typed function pointer that calls another function, so that when I create an array with the struct as type and I initialize the array like this:
opcodes = new OpcodeHandler[max_opcodes]
{
new OpcodeHandler("someopcodenamehere", Somefunctionname);
// more new's..
}
That the function named in the second argument of the constructor : 'Somefunctionname' gets called when calling the function pointer. I've heard that this is possible with delegates since they behave just like function pointers in C++, but all of my tries were useless.