![]() |
Is it legal that a function pointer to "function with default arguments"?
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? |
Re: Is it legal that a function pointer to "function with default arguments"?
"Ajax Chelsea" <ajaxchelsea@163.com> wrote in message news:625675e4.0312012322.30a87010@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." |
| All times are GMT. The time now is 05:00 AM. |
Powered by vBulletin®. Copyright ©2000 - 2013, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.