Topic: 8.3.5/9 function pointers
Author: "Ivan Novick" <ivan.d.novick@gmail.com>
Date: Tue, 13 Feb 2007 11:44:42 CST Raw View
Hi,
When discussing function pointers,
The examples seem to indicate that if a return type is ommitted the
return type is int, and if the return type has only a * the return
type is a pointer to int.
*fpi(int) // return pointer to int
(* pif )( const char *, const char *) // returns int
So can we say that the default return type if it is ommited for a
function pointer is int, or int*, and that it is valid to leave out
the return type when specifying a function pointer?
If it is valid, would not be sensible to explicity state this in the
standard, in addition to showing an example?
Thanks,
Ivan Novick
http://www.0x4849.net
---
[ comp.std.c++ is moderated. To submit articles, try just posting with ]
[ your news-reader. If that fails, use mailto:std-c++@ncar.ucar.edu ]
[ --- Please see the FAQ before posting. --- ]
[ FAQ: http://www.comeaucomputing.com/csc/faq.html ]
Author: Pete Becker <pete@versatilecoding.com>
Date: Tue, 13 Feb 2007 12:15:43 CST Raw View
Ivan Novick wrote:
>
> The examples seem to indicate that if a return type is ommitted the
> return type is int, and if the return type has only a * the return
> type is a pointer to int.
>
The example is a bit tricky.
> *fpi(int) // return pointer to int
> (* pif )( const char *, const char *) // returns int
>
What it actually says for those two is:
int i,
*pfi(int),
(*pif)(const char*, const char*),
Note the "int i," at the beginning. Because of that, each of these has
an "int" in front, just like
int i, j;
--
-- Pete
Roundhouse Consulting, Ltd. (www.versatilecoding.com)
Author of "The Standard C++ Library Extensions: a Tutorial and
Reference." (www.petebecker.com/tr1book)
---
[ comp.std.c++ is moderated. To submit articles, try just posting with ]
[ your news-reader. If that fails, use mailto:std-c++@ncar.ucar.edu ]
[ --- Please see the FAQ before posting. --- ]
[ FAQ: http://www.comeaucomputing.com/csc/faq.html ]
Author: gennaro.prota@yahoo.com (Gennaro Prota)
Date: Tue, 13 Feb 2007 18:19:39 GMT Raw View
On Tue, 13 Feb 2007 11:44:42 CST, Ivan Novick wrote:
>Hi,
>
>When discussing function pointers,
>
>The examples seem to indicate that if a return type is ommitted the
>return type is int, and if the return type has only a * the return
>type is a pointer to int.
It isn't omitted, it's just not repeated, as in
int a,
b;
Genny.
---
[ comp.std.c++ is moderated. To submit articles, try just posting with ]
[ your news-reader. If that fails, use mailto:std-c++@ncar.ucar.edu ]
[ --- Please see the FAQ before posting. --- ]
[ FAQ: http://www.comeaucomputing.com/csc/faq.html ]
Author: "Ivan Novick" <ivan.d.novick@gmail.com>
Date: Tue, 13 Feb 2007 17:31:45 CST Raw View
On Feb 13, 10:15 am, Pete Becker <p...@versatilecoding.com> wrote:
> Ivan Novick wrote:
>
> > The examples seem to indicate that if a return type is ommitted the
> > return type is int, and if the return type has only a * the return
> > type is a pointer to int.
>
> The example is a bit tricky.
>
> > *fpi(int) // return pointer to int
> > (* pif )( const char *, const char *) // returns int
>
> What it actually says for those two is:
>
> int i,
> *pfi(int),
> (*pif)(const char*, const char*),
>
> Note the "int i," at the beginning. Because of that, each of these has
> an "int" in front, just like
>
> int i, j;
Hmm... how about adding:
[Note: the return type of these functions is being indicated from the
int at the beginning of the declaration and it is not required to be
repeated similar to this declaration int i, j;]
Or something to this effect for the unsuspecting reader ;)
Ivan Novick
http://www.0x4849.net
---
[ comp.std.c++ is moderated. To submit articles, try just posting with ]
[ your news-reader. If that fails, use mailto:std-c++@ncar.ucar.edu ]
[ --- Please see the FAQ before posting. --- ]
[ FAQ: http://www.comeaucomputing.com/csc/faq.html ]
Author: pete@versatilecoding.com (Pete Becker)
Date: Wed, 14 Feb 2007 15:52:53 GMT Raw View
Ivan Novick wrote:
> On Feb 13, 10:15 am, Pete Becker <p...@versatilecoding.com> wrote:
>>
>> int i,
>> *pfi(int),
>> (*pif)(const char*, const char*),
>>
>> Note the "int i," at the beginning. Because of that, each of these has
>> an "int" in front, just like
>>
>> int i, j;
>
> Hmm... how about adding:
>
> [Note: the return type of these functions is being indicated from the
> int at the beginning of the declaration and it is not required to be
> repeated similar to this declaration int i, j;]
>
> Or something to this effect for the unsuspecting reader ;)
>
The standard is written for experts.
--
-- Pete
Roundhouse Consulting, Ltd. (www.versatilecoding.com)
Author of "The Standard C++ Library Extensions: a Tutorial and
Reference." (www.petebecker.com/tr1book)
---
[ comp.std.c++ is moderated. To submit articles, try just posting with ]
[ your news-reader. If that fails, use mailto:std-c++@ncar.ucar.edu ]
[ --- Please see the FAQ before posting. --- ]
[ FAQ: http://www.comeaucomputing.com/csc/faq.html ]