QH Hong wrote in news:16**************************@posting.google.c om:

How should I define the "function"?

You tried (using an invalid expression a.member_fuction_name) to

convert a member function to a non-member (aka free/global/regular)

function, the language doesen't provide any way of doing this.

The folowing may help solve your problem using a "Functor".

#include <iostream>

#include <ostream>

/* Simple Functor

*/

struct tCls

{

double operator () ( double x ) const

{

return x + 3.145926;

}

};

/* A regular function is also a Functor

*/

double func1(double x)

{

return x + 2.0;

}

template < typename function >

double solve (function f, double x)

{

return f(x) + 3.0;

}

int main()

{

tCls a;

std::cout << solve(func1, 1.0) << "\n";

std::cout << solve( a, 2.0) << std::endl;

}

HTH.

Rob.

--

http://www.victim-prime.dsl.pipex.com/