From 979694941440520596
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: f78e5,fb1a92fa405c930c
X-Google-Attributes: gidf78e5,public
From: clamage@eng.sun.com (Steve Clamage)
Subject: Re: nested functions
Date: 1999/06/10
Message-ID: <7jp0l8$s1r$1@engnews1.eng.sun.com>#1/1
X-Deja-AN: 488088715
Approved: Valentin Bonnard <bonnard@clipper.ens.fr>
References: <7jd4c5$nup$1@nnrp1.deja.com> <7jjjr6$r02$1@nnrp1.deja.com> <7jma5c$i85@abyss.West.Sun.COM> <37dd56e1.565652003@nntp.ix.netcom.com>
X-Original-Date: 10 Jun 1999 18:37:28 GMT
Organization: Sun Microsystems Inc., Mountain View, CA
X-Auth: PGPMoose V1.1 PGP comp.std.c++ iQBVAwUAN2A3P6wEuYhIxRhxAQEv9wH+M+HO8hOCmhC5ybCmxQzoP4SFEWZaYeRP tZorq/7gJQiPXCEnmFpx5EJc1FtZTjASDpIf1SS0QqDyHkiSHQ/UJg== =WgPD
Newsgroups: comp.std.c++

source@netcom.com (David Harmon) writes:

>Also, a local function can only be called from within the context of a
>function that knows about it.  Returning a pointer to a local function
>would be undefined, just like returning a pointer to an auto variable. ...

>Code elsewhere needs no overhead added to the calling sequence.

What about this:

typedef int (*fp)(int);

extern void foo(fp);

int main()
{
    int g(int) { ... } // local function
    foo(g); // passed to a function that doesn't know about g or main
}

--
Steve Clamage, stephen.clamage@sun.com
---
[ 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://reality.sgi.com/austern_mti/std-c++/faq.html              ]



