Xref: utzoo comp.lang.c++:13509 comp.lang.c:39340 Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!zaphod.mps.ohio-state.edu!pacific.mps.ohio-state.edu!linac!unixhub!ditka!comeau From: comeau@ditka.Chicago.COM (Greg Comeau) Newsgroups: comp.lang.c++,comp.lang.c Subject: Re: Pointers to functions Message-ID: <39059@ditka.Chicago.COM> Date: 17 May 91 05:17:58 GMT References: Sender: comeau@ditka.Chicago.COM (Greg Comeau) Reply-To: comeau@csanta.attmail.com (Greg Comeau) Followup-To: comp.lang.c++ Organization: Comeau Computing Lines: 26 In article aj3u@wilbury.cs.virginia.edu (Asim Jalis) writes: >pf = hello; and pf = &hello; >The definitions for pf and hello are as follows: >void (*pf)(); // pointer to a function >void hello() { printf("Hello World\n"); } >I used the two different forms of assignments and got the same output. >Is there a difference between them? There is a difference even though they both end up at the same. In 'pf = hello;', the function name expression is implicitly converted into a pointer to a function of the appropriate type (a void(*)()) when in this context. With 'pf = &hello;', since the operand of & is a function, it is a pointer to a function of the appropriate type. It does not become a pointer to a pointer to a function. The C++ style is to use the & form. - Greg -- Comeau Computing, 91-34 120th Street, Richmond Hill, NY, 11418 Producers of Comeau C++ 2.1 Here:attmail.com!csanta!comeau / BIX:comeau / CIS:72331,3421 Voice:718-945-0009 / Fax:718-441-2310