• Advertisement
Sign in to follow this  

Does this function pointer make sense?

This topic is 4327 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I've been trying to get this right but I am having a lot of trouble: double (*inputFunc)((list<double>) &); this is suppose to be a function pointer to a function that might look like:
double haha(list<double> &x)
{
  // do stuff to x
  return 0.0;
}


Is this correct? The compiler disagrees with me, but I don't know what I should do to correct it(and I have not had too much exposure to function pointers).

Share this post


Link to post
Share on other sites
Advertisement
Quote:
Original post by Sagar_Indurkhya
double (*inputFunc)((list<double>) &);


Well thar's yar problem. You forgot yar typedef.

typedef double (*inputFunc)((list<double>) &);

Share this post


Link to post
Share on other sites
Quote:
Original post by Programmer One
Quote:
Original post by Sagar_Indurkhya
double (*inputFunc)((list<double>) &);


Well thar's yar problem. You forgot yar typedef.

typedef double (*inputFunc)((list<double>) &);


Shouldn't it be:
typedef double (*inputFunc)(list<double>&);

Without the extra parentheses?

Share this post


Link to post
Share on other sites
I'll go ahead and throw out the obligatory recommendation for boost::function. Also, it would clean up your code a bit if you utilized the awe-inspiring power of the typedef mechanism: typdef list<double> DoubleList.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement