D
Dave
Hello all,
Can anybody help with the problem below? I'm trying to define a conversion
function that converts objects to function pointers and am getting a compile
error on the line indicated below. The compiler interprets this is a
function returning a function, which, of course is illegal... What is the
correct syntax to accomplish this?
Thanks,
Dave
#include <iostream>
using namespace std;
double foo_func(int n) {return n + 1.5;}
class foo_t
{
public:
operator double (*)(int)() {return foo_func;} // Compile error here!
};
int main()
{
foo_t f;
cout << f(12) << endl; // Expecting "13.5"...
return 0;
}
Can anybody help with the problem below? I'm trying to define a conversion
function that converts objects to function pointers and am getting a compile
error on the line indicated below. The compiler interprets this is a
function returning a function, which, of course is illegal... What is the
correct syntax to accomplish this?
Thanks,
Dave
#include <iostream>
using namespace std;
double foo_func(int n) {return n + 1.5;}
class foo_t
{
public:
operator double (*)(int)() {return foo_func;} // Compile error here!
};
int main()
{
foo_t f;
cout << f(12) << endl; // Expecting "13.5"...
return 0;
}