Sign in to follow this  
Sagar_Indurkhya

Does this function pointer make sense?

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
Programmer One    746
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
CTar    1134
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
nilkn    960
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

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this