home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #16 / NN_1992_16.iso / spool / comp / lang / cplus / 11427 < prev    next >
Encoding:
Text File  |  1992-07-23  |  1.2 KB  |  32 lines

  1. Newsgroups: comp.lang.c++
  2. Path: sparky!uunet!newsgate.watson.ibm.com!yktnews!admin!siena!mittle
  3. From: mittle@watson.ibm.com (Josh Mittleman)
  4. Subject: Re: inlining a virtual function.
  5. Sender: news@watson.ibm.com (NNTP News Poster)
  6. Message-ID: <1992Jul23.195945.12821@watson.ibm.com>
  7. Date: Thu, 23 Jul 1992 19:59:45 GMT
  8. Disclaimer: This posting represents the poster's views, not necessarily those of IBM
  9. References:  <1992Jul23.171751.10146@Warren.MENTORG.COM>
  10. Nntp-Posting-Host: siena.watson.ibm.com
  11. Organization: IBM T.J. Watson Research Center
  12. Keywords: inline virtual
  13. Lines: 17
  14.  
  15. > class A {
  16. >   virtual int f() { return 1; }
  17. > };
  18.  
  19. > "x.c", line 1: warning: virtual function  A::f() cannot be inlined
  20.  
  21. > My question is why CANT we inline a virtual function?
  22.  
  23. An inline function does not have an address, because it does not generate a
  24. function call.  Instead, it is expanded at compile time (sort of like a
  25. macro).  A virtual function has to have an address, which will be stored in
  26. the virtual function table, and must always be accessed through a function
  27. call. 
  28.  
  29. ===========================================================================
  30. Josh Mittleman (mittle@watson.ibm.com)
  31. J2-C28 T.J. Watson Research Center, PO Box 704, Yorktown Heights, NY  10598
  32.