home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.lang.c++
- Path: sparky!uunet!newsgate.watson.ibm.com!yktnews!admin!siena!mittle
- From: mittle@watson.ibm.com (Josh Mittleman)
- Subject: Re: inlining a virtual function.
- Sender: news@watson.ibm.com (NNTP News Poster)
- Message-ID: <1992Jul23.195945.12821@watson.ibm.com>
- Date: Thu, 23 Jul 1992 19:59:45 GMT
- Disclaimer: This posting represents the poster's views, not necessarily those of IBM
- References: <1992Jul23.171751.10146@Warren.MENTORG.COM>
- Nntp-Posting-Host: siena.watson.ibm.com
- Organization: IBM T.J. Watson Research Center
- Keywords: inline virtual
- Lines: 17
-
- > class A {
- > virtual int f() { return 1; }
- > };
-
- > "x.c", line 1: warning: virtual function A::f() cannot be inlined
-
- > My question is why CANT we inline a virtual function?
-
- An inline function does not have an address, because it does not generate a
- function call. Instead, it is expanded at compile time (sort of like a
- macro). A virtual function has to have an address, which will be stored in
- the virtual function table, and must always be accessed through a function
- call.
-
- ===========================================================================
- Josh Mittleman (mittle@watson.ibm.com)
- J2-C28 T.J. Watson Research Center, PO Box 704, Yorktown Heights, NY 10598
-