brian@bucc2.UUCP (04/23/88)
In C++, are pointers to the member functions stored with an object???
Or are function pointers stored only for virtual member functions?
...............................................................................
When the going gets weird, the weird turn pro.
Brian Michael Wendt UUCP: {cepu,ihnp4,uiucdcs,noao}!bradley!brian
Bradley University ARPA: cepu!bradley!brian@seas.ucla.edu
(309) 691-5175 ICBM: 40 40' N 89 34' Wark@alice.UUCP (04/26/88)
In article <13200001@bucc2>, brian@bucc2.UUCP writes: > In C++, are pointers to the member functions stored with an object??? No. > Or are function pointers stored only for virtual member functions? Each object that contains one or more virtual functions has a single pointer to a ``virtual function table'' that corresponds to the class of that object. The table has one entry for each virtual function member of that class. Multiple objects can share the same table.
mikem@otc.oz (Mike Mowbray) (04/28/88)
In article <13200001@bucc2>, brian@bucc2.UUCP says: > In C++, are pointers to the member functions stored with an object??? No. You must supply a specific object instance to invoke the pointed-to member function. > Or are function pointers stored only for virtual member functions? They are stored for all kinds of member functions. The trick for correctly storing and invoking ptrs-to-virtual-member-fns is a bit subtle. Write some example code and then look at the C-code generated. Mike Mowbray Systems Development |||| OTC || PHONE (02) 287-4104 ACSnet: mikem@otc.oz FAX (02) 287-4990 UUCP: {uunet,mcvax}!otc.oz!mikem SNAIL OTC, GPO Box 7000 CSNET: mikem@otc.oz.au Sydney 2001, Australia ARPA: mikem@otc.oz.au
chris@mimsy.UUCP (Chris Torek) (04/28/88)
In article <13200001@bucc2> brian@bucc2.UUCP writes: >In C++, are pointers to the member functions stored with an object??? There is an easy way to find out: run cfront over a class definition and see what it emits. Answer: no. >Or are function pointers stored only for virtual member functions? Here a single pointer is stored, to the `virtual function table'. -- In-Real-Life: Chris Torek, Univ of MD Comp Sci Dept (+1 301 454 7163) Domain: chris@mimsy.umd.edu Path: uunet!mimsy!chris