Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!csd4.milw.wisc.edu!cs.utexas.edu!uunet!cimshop!davidm From: davidm@cimshop.UUCP (David Masterson) Newsgroups: comp.lang.c++ Subject: Re: Objectifying incoming messages? Message-ID: <448@cimshop.UUCP> Date: 29 Jul 89 01:22:09 GMT References: <444@cimshop.UUCP> <1273@cbnewsl.ATT.COM> Organization: Consilium Mt. View CA Lines: 27 In-reply-to: dog@cbnewsl.ATT.COM's message of 27 Jul 89 13:57:45 GMT >The same problem arises reading objects from disk. Until you look at >the data, you don't know what class of object to instance so it >can read itself. It seems to me, this is one place you still >need a header/type field and a switch statement. > Agreed. In fact, my messages deal with a database server to get information from the database. I think a function pointer table is a cleaner way of implementing this in C, but can you implement an object construction pointer table in C++? By the way, would the object/function that reads from the external entity be a separate thing or should it be a base class that looks at itself and casts to the appropriate derived class (can that even be done?!?)? Consider: 1. All external objects have a common header in order to determine what type of object they are. 2. A generic object would get the external object and decide what to do with it. 3. Once it decides, it makes (casts) itself a specific object of the appropriate type. What problems are there in this method? I think I see a few, but I'm curious about what others think? (I'm looking for ammunition ;-) David Masterson uunet!cimshop!davidm