I’m having trouble in getting the pointer of a function that I access through pointers:
double *d = &(this->c1->...->myFunc();
does not work, myFunc() is declared as double.
Is there a way of doing this?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
If you mean that you want a pointer to the value returned by
myFunc, then you can’t: it’s a temporary, and will be destroyed at the end of the expression.If you need a pointer, then you’ll also need a non-temporary value to point at:
Or are you saying that you want a pointer to the function? That’s a different type to
double*:Or are you saying that you want something you can call like a simple function, but bound to some object
this->c1->...? The language doesn’t directly support that, but C++11 has lambdas and abindfunction for that sort of thing: