On Monday 13 September 2004 17:05, John Lamb wrote:
This compiles and works under gcc 3.3.3, but I suspect it's not legal int main() { double (*function)( double, double = 0 ) = ::function;
My guess is you are wrong. Your code is right. A pointer is a scalar value, and I don't believe the language cares what it points to when it comes to initialization.
I found the answer eventually, in footnote 84 of the C++ draft standard: pointers to functions and typedefs are not allowed to have default parameters. Since overloaded operators can have default parameters, it's possible to get nearly the same effect legally with (say) struct Function { double operator()( double, double = 0 ) const; static Function& instance(){ static Function* function; return *function; } private: Function(){}; }; ... Function& function = Function::instance(); But, should a language be this cryptic? -- JDL