Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!uunet!taumet!steve From: steve@taumet.com (Stephen Clamage) Newsgroups: comp.lang.c++ Subject: Re: Virtual functions and inline Message-ID: <617@taumet.com> Date: 1 Mar 91 17:03:54 GMT References: <1991Feb28.141548.2043@cs.nott.ac.uk> Organization: Taumetric Corporation, San Diego Lines: 19 gas@cs.nott.ac.uk (Alan Shepherd) writes: >Is it okay to declare virtual functions inline ? Even though the code >to be excuted is substituted rather than a function call made, does >the correct method still get called ? It is okay to declare inline virtual functions. The compiler will instantiate (make a real copy of) the function and put its address in the table of virtual functions for the class. In general, it is not possible to tell which version of a virtual function will be called until run time, so there is no choice but to do this. In some cases it can be determined at compile time that a particular virtual function is being called, and a nice compiler will substitute it inline. Remember that "inline" is a "hint" to the compiler, and it is not required to generate inline code for any function. -- Steve Clamage, TauMetric Corp, steve@taumet.com