Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

I'm trying to declare a std::map that is keyed by a char and has a function pointer as a second parameter, these functions would be a member function of my class. But for some odd reason I cannot call the functions when extracted...

 

So, I have a class A as shown below, it contains a map as well as a function

 


class A
{
private:
map<char, void (A::*)(void)> mapA;
public:
void func();

[/Code]

 

Next I have main code that looks like this:

[Code]
A::A() // constructor
{
// Generate User Options
mapA['a'] = &A::func;
}
[/Code]

 

Now, I try to execute func by extracting it from the map and running the function:

[Code]
map<char, void (A::*)(void)>::iterator it;
for ( it=mapA.begin() ; it != mapA.end(); it++ )
{
(*it).second();
}
[/Code]

 

I would assume this would launch function "func" as it is stored in the map, but instead it generates the following error message:

error C2064: term does not evaluate to a function taking 0 arguments

 

Any help would be greatly appreciated...

Thanks,

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...