home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #31 / NN_1992_31.iso / spool / comp / lang / cplus / 18505 < prev    next >
Encoding:
Text File  |  1992-12-29  |  1.9 KB  |  48 lines

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