class Node:private
{
private:
struct NetCommands
{
char *Command;
void (Node::*pFunction) (char *pData);
}CommandList [COMMAND];
void ParseData (char *pBuffer);
public:
Node:: Node(int Port, int MaxConnections);
};
Node:: Node(int Port, int MaxConnections)
{
CommandList[1].Command = "Verify";
CommandList[1].pFunction = &Node::VerifyClient;
CommandList[2].Command = "Disconnect";
CommandList[2].pFunction = &Node::DisconnectClient;
}
void Node::ParseData (char *pBuffer)
{
//parse code
((this->CommandList[Loop]).*pFunction)(pDividedData); //-> ERROR: pFunction undeclared (first use this function)
//parse code
}
pointer to member function (with nested classes)
Hi,
I have a list with possible commands that I can recieve from a client. When I find the right command I call the function that fits with it (a pointer to a member function). The problem is that the call to this function won't work.
Some extracts from my code to clarify:
If anyone else know's a better methode to execute command's from a client feel free to post it here :).
[Edited by - Rip7 on February 8, 2005 11:53:20 AM]
I believe you misused the function pointers. I think you should use something like:
(PS: use either
void Node::ParseData (char *pBuffer){//parse code// YOURS: ((this->CommandList[Loop]).*pFunction)(pDividedData); (this->*(CommandList[Loop].pFunction))(pDividedData);//parse code}
(PS: use either
or [ source ] tags, not <code>)<br><br>HTH,
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement