"Ajax Chelsea" <aj*********@163.com> wrote in message news:62**************************@posting.google.c om...
1,int (*f)(int a = 1);//is it legal?
2,int (*f)(int a = 1);
int g(int a = 2){return 0;}
f = &g;//is it legal?
First, default args have no affect on function type.
int g(int a=2)
has type int ()(Int) NOT int()()
Second, default args are not allowed in pointer declarations.
8.3.6 / 3 specifically covers it (and the point is driven home by the footnote
that specifically says "This means that default arguments cannot appear,
for example, in declarations of pointers to functions, references to functions, or
typedef declarations."