home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #30 / NN_1992_30.iso / spool / comp / lang / cplus / 18070 < prev    next >
Encoding:
Text File  |  1992-12-16  |  1.3 KB  |  49 lines

  1. Newsgroups: comp.lang.c++
  2. Path: sparky!uunet!taumet!steve
  3. From: steve@taumet.com (Steve Clamage)
  4. Subject: Re: & of inline functions
  5. Message-ID: <1992Dec16.181807.25828@taumet.com>
  6. Organization: TauMetric Corporation
  7. References: <1992Dec13.185310.20140@math.ufl.edu> <1992Dec15.233031.11712@news.mentorg.com>
  8. Date: Wed, 16 Dec 1992 18:18:07 GMT
  9. Lines: 38
  10.  
  11. dgrammel@dgrammel.mentorg.com (Dave Grammel) writes:
  12.  
  13. >In article <1992Dec13.185310.20140@math.ufl.edu>, x9999bvj@maple.circa.ufl.edu writes:
  14. >|> 
  15. >|> What is the official method for handling taking the address of an inline
  16. >|> function?
  17.  
  18. >Don't make it inline.
  19.  
  20. Nonsense.  An inline function is just a function.  You take its address
  21. in exactly the same way as you would any function of its type.
  22. Examples:
  23.  
  24.     inline int ordinary(int i) { return i; }
  25.  
  26.     int (*fp)(int) = ordinary;
  27.  
  28.     class X {
  29.     public:
  30.         int member(int i) { return i; } // inline
  31.     };
  32.  
  33.     int (X::*mfp)(int) = &X::member;
  34.  
  35. In such cases, the compiler will create a callable version of the
  36. inline function for you, and use that address.  You could then have
  37. both inline and non-inline uses of the function in the same program.
  38. Continuing the previous examples:
  39.  
  40.     foo()
  41.     {
  42.         int j = ordinary(3);    // expanded inline
  43.         int k = fp(4);        // called via the pointer
  44.         ...
  45.     }
  46. -- 
  47.  
  48. Steve Clamage, TauMetric Corp, steve@taumet.com
  49.