home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1993 #1 / NN_1993_1.iso / spool / comp / std / cplus / 2005 < prev    next >
Encoding:
Internet Message Format  |  1993-01-08  |  1.5 KB

  1. Path: sparky!uunet!gatech!usenet.ins.cwru.edu!agate!agate!matt
  2. From: matt@physics2.berkeley.edu (Matt Austern)
  3. Newsgroups: comp.std.c++
  4. Subject: Re: C++ already *has* nested functions SO WHAT'S THE BEEF?
  5. Date: 8 Jan 93 10:04:28
  6. Organization: Lawrence Berkeley Laboratory (Theoretical Physics Group)
  7. Lines: 21
  8. Message-ID: <MATT.93Jan8100428@physics2.berkeley.edu>
  9. References: <1992Dec21.080952.15309@netcom.com> <harvey.726175866@regina>
  10.     <9300811.3521@mulga.cs.mu.OZ.AU>
  11. Reply-To: matt@physics.berkeley.edu
  12. NNTP-Posting-Host: physics2.berkeley.edu
  13. In-reply-to: fjh@munta.cs.mu.OZ.AU's message of Fri, 8 Jan 1993 00:39:33 GMT
  14.  
  15. In article <9300811.3521@mulga.cs.mu.OZ.AU> fjh@munta.cs.mu.OZ.AU (Fergus James HENDERSON) writes:
  16.  
  17. > The classic
  18. > sort of example where nested functions are useful is
  19.  
  20.   [Example of passing a function pointer to qsort deleted]
  21.  
  22. > Because the interface to qsort() is fixed, the alternative is to use a rather
  23. > ugly hack using global variables (well, ok, you can make them file-scope
  24. > static variables rather than real global variables).
  25.  
  26. Correct; that's just where nested function would be nice.
  27.  
  28. And note that encapsulating compare() in some class is not a solution:
  29. qsort expects its argument to be a function pointer, not a member
  30. function pointer.
  31. --
  32. Matthew Austern                   Just keep yelling until you attract a
  33. (510) 644-2618                    crowd, then a constituency, a movement, a
  34. austern@lbl.bitnet                faction, an army!  If you don't have any
  35. matt@physics.berkeley.edu         solutions, become a part of the problem!
  36.