Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!wuarchive!mit-eddie!snorkelwacker!ai-lab!rice-chex!rpk From: rpk@rice-chex.ai.mit.edu (Robert Krajewski) Newsgroups: comp.lang.c++ Subject: Re: Efficient compilation of virtual functions Message-ID: <10294@life.ai.mit.edu> Date: 23 Aug 90 22:49:06 GMT References: <1990Aug22.193347.18486@ux1.cso.uiuc.edu> Sender: news@ai.mit.edu Organization: MIT Artificial Intelligence Laboratory Lines: 19 In article <1990Aug22.193347.18486@ux1.cso.uiuc.edu> nelson@suna2.UUCP (Taed Nelson) writes: > >If we have a virtual member function in the base class, and the same member > function is redeclared in the subclass, whenever we are using an instance > of the subclass, there is _no need_ to consult the virtual function table > since we will _always_ call the subclass function. This does not obtain if you allow separate compilation. A virtual function call can only be resolved statically (that is, by the compiler), if it knows that the subclass really lies at the end of the tree (i.e., none of *its* subclasses implements the same virtual function). A linker could do this sort of thing if it was given the entire class tree to look at during the link process. A compiler could do it if you told it that the class tree that it knew about was the whole enchilada. Robert P. Krajewski Internet: rpk@ai.mit.edu ; Lotus: robert_krajewski.lotus@crd.dnet.lotus.com