Path: utzoo!news-server.csri.toronto.edu!cs.utexas.edu!sdd.hp.com!think.com!linus!agate!ucbvax!pasteur!galileo.berkeley.edu!jbuck From: jbuck@galileo.berkeley.edu (Joe Buck) Newsgroups: comp.std.c++ Subject: Re: type/member tags (was Re: asking an object for its type) Message-ID: <11792@pasteur.Berkeley.EDU> Date: 8 Mar 91 19:41:33 GMT References: <27C2D973.3C1B@tct.uucp> <70877@microsoft.UUCP> <10721@dog.ee.lbl.gov> Sender: news@pasteur.Berkeley.EDU Reply-To: jbuck@galileo.berkeley.edu (Joe Buck) Lines: 24 In article <10721@dog.ee.lbl.gov>, beard@ux5.lbl.gov (Patrick C Beard) writes: |> The information about what class an object is can be easily obtained by using |> the pointer to the object's virtual function table as the class id, which |> whill always be unique for every class. This could be quite easy to add |> to the language and easy to implement. Class relationships would be easy |> to implement by putting a link field in the vtable which points to a |> class's super-class. False. Several reasons: 1). The language standard says nothing about virtual function tables. It only specifies the effect of calling virtual functions. A different data structure could be used, and in some cases might be more efficient. 2). You can't count on testing two objects for the same type by comparing their vtbl pointers anyway. The compiler may have had to duplicate the vtbl; for example, because of incremental linking or because it didn't have enough information to avoid generating the table more than once. -- Joe Buck jbuck@galileo.berkeley.edu {uunet,ucbvax}!galileo.berkeley.edu!jbuck