Path: utzoo!attcan!utgpu!jarvis.csri.toronto.edu!mailrus!csd4.csd.uwm.edu!cs.utexas.edu!milano!cadillac!puma!vaughan From: vaughan@puma.cad.mcc.com (Paul Vaughan) Newsgroups: comp.lang.c++ Subject: swapping virtual function table pointers Message-ID: <2438@cadillac.CAD.MCC.COM> Date: 21 Aug 89 18:20:18 GMT Sender: news@cadillac.CAD.MCC.COM Lines: 24 I occasionally have related classes with identical data and function members but differing virtual function definitions. I'd like to be able to change the behavior of objects of such classes by changing the virtual function table pointer in the existing objects. I use g++ 1.35.1 at the moment. Three questions: 1) Is this feasible in cfront 2.0 and/or g++? 2) Is it possible to define in a portable way within the language? 3) Could anyone share a hack to do this? Now for something more complex, assuming I'm not already totally fouled up. Suppose I copied a virtual function table for some class and changed the virtual function table pointer of an instance of that class to point to the copy. Now suppose I were to change individual elements of this copied table in order to dynamically change the behavior of an object. 1) Has anybody tried this? 2) Does it sound feasible? Paul Vaughan, MCC CAD Program | ARPA: vaughan@mcc.com | Phone: [512] 338-3639 Box 200195, Austin, TX 78720 | UUCP: ...!cs.utexas.edu!milano!cadillac!vaughan