On 2008-10-19 04:10:08 -0400, "Bruce !C!+" <aa*******@163.comsaid:
>
template <typename T>
T (*getOp())(T, T)
{
return &Minus;
}
int main()
{
cout<< (*getOp())(3,4)<<endl; //compile error: no matching function
for call to ‘getOp()’
}
why "no matching function for call to ‘getOp()’" ???
Because getOp takes no arguments, so a plain call like that one doesn't
provide any way to figure out what type T should be. Use getOp<int>().
--
Pete
Roundhouse Consulting, Ltd. (
www.versatilecoding.com) Author of "The
Standard C++ Library Extensions: a Tutorial and Reference
(
www.petebecker.com/tr1book)