Velocity Reviews

Velocity Reviews (http://www.velocityreviews.com/forums/index.php)
-   C++ (http://www.velocityreviews.com/forums/f39-c.html)
-   -   Is it legal that a function pointer to "function with default arguments"? (http://www.velocityreviews.com/forums/t279683-is-it-legal-that-a-function-pointer-to-function-with-default-arguments.html)

Ajax Chelsea 12-02-2003 07:22 AM

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?

Ron Natalie 12-02-2003 02:01 PM

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 01:52 AM.

Powered by vBulletin®. Copyright ©2000 - 2014, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.