From -7690007821704044386 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 109fba,ac06fef48c3c04df X-Google-Attributes: gid109fba,public X-Google-Thread: f78e5,ac06fef48c3c04df X-Google-Attributes: gidf78e5,public X-Google-ArrivalTime: 1995-01-25 07:41:06 PST Path: nntp.gmd.de!newsserver.jvnc.net!yale.edu!noc.near.net!transfer.stratus.com!news.mathworks.com!panix!usenet From: Viktor Yurkovsky Newsgroups: comp.lang.c++,comp.std.c++ Subject: Re: friends and local classes Date: 25 Jan 1995 15:41:06 GMT Organization: PANIX Public Access Internet and Unix, NYC Lines: 34 Message-ID: <3g5rei$dl8@news.panix.com> References: <3g5qc6$16p@news.cc.utah.edu> NNTP-Posting-Host: 166.84.254.241 Xref: nntp.gmd.de comp.lang.c++:87869 comp.std.c++:11246 swillden@fcom.cc.utah.edu (Shawn Willden) wrote: > > Sam Fenster (fenster@ground.cs.columbia.edu) wrote: > : Ideally, we'd have local functions too, for similar reasons (e.g. a comparison > : function to pass to "qsort"). I don't expect that soon. But let's not get > : rid of local classes, OK? > > Just make a local class with a static function if you need a local function. > > void functionWithLocalFunction() > { > struct Local > { > int static compare(const void* a, const void* b) > { > const int *intA = reinterpret_cast(a); > const int *intB = reinterpret_cast(b); > if (*intA == *intB) > return 0; > else if (*intA < *intB) > return -1; > else > return 1; > } > }; > > //... > qsort(array, sizeof(array)/sizeof(array[0]), sizeof(array), > &Local::compare); > } > >... Hmm.. This creates a rather large inline, doesn't it?