Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!uunet!stanford.edu!neon.Stanford.EDU!news From: philip@pescadero.stanford.edu (Philip Machanick) Newsgroups: comp.lang.c++ Subject: Re: Need help, missing virtual tables, Sun C++ 2.0 Message-ID: <1991May10.182759.28323@neon.Stanford.EDU> Date: 10 May 91 18:27:59 GMT References: <1991May8.224321.12580@cs.utk.edu> <1991May9.173442.5946@dragon.wpd.sgi.com> Sender: news@neon.Stanford.EDU (USENET News System) Organization: Computer Science Department, Stanford University Lines: 25 In article <1991May9.173442.5946@dragon.wpd.sgi.com> pal@xanadu.wpd.sgi.com (Anil Pal) writes: >The trick here is understanding where the translator puts the virtual >function table. In order to reduce the number of copies of the virtual >function table, cfront-based translators (I believe Sun C++ 2.0 is one) >use the following strategy: > > The virtual function table for a class is output in a compilation > stream if the compilation stream contains the *definition* for the > first non-inline virtual function *declared* in that class. Simple :-) > Consider a class with only inline virtual functions, like class thing {public: virtual void incr () {i++;} private: int i; }; When is the translator going to generate the virtual function table for this? (Is it going to give up on trying to be optimal in this case and just generate it in every file where the header is included?) Philip Machanick