home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.lang.c++
- Path: sparky!uunet!ulowell!cs.ulowell.edu!jrichard
- From: jrichard@cs.ulowell.edu (John 'MacGyver' Richardson)
- Subject: help with virtual functions
- Message-ID: <C0172J.66L@ulowell.ulowell.edu>
- Sender: usenet@ulowell.ulowell.edu (News manager - ulowell)
- Organization: University of Massachusetts at Lowell Computer Science
- Date: Tue, 29 Dec 1992 17:25:30 GMT
- Lines: 37
-
-
- I'm trying to use classes with virtual function in a shared memory array.
- After reading Coplien's "Advanced C++" (p. 269) and learning that pointers
- would be a problem, I think I'm going to have to go back to C (or at least
- C++ without virtual functions).
-
- My application has a database filled with objects, all derived from the
- same class.
-
- I've thought of a few workarounds for this problem.
-
- o Move the objects outside of the shared memory and keep pointers
- to the shared memory an object needs. This involves keeping a
- distinct tag field so each process can determine what type of
- object it should create to point to the shared memory. Of course,
- new processes will have to switch() on the tag to create the
- correct object for each entry in the array.
-
- o Keep objects in the shared memory with a tag field to determine
- sub-object type (types that would have been derived). This
- looses the biggest advantage of C++ though and we're back to the
- switch statement!
-
- o Make one process handle everything. Sounds easy, but IO is painful
- I.E. Trying to insure that one accesser doesn't tie up the
- database by repeated IO requests or one large request is hard to do.
-
-
- I noticed some talk earlier about saving arrays of classes and such and
- along the lines someone mentioned that a better C++ programmer would have
- a workaround for these "virtual" problems. Are there any?? If you know of
- any, can you mail it off to me?
-
- Thanks,
-
- John Richardson
- jrichard@cs.ulowell.edu
-