home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #16 / NN_1992_16.iso / spool / comp / lang / cplus / 11223 < prev    next >
Encoding:
Text File  |  1992-07-21  |  1.7 KB  |  52 lines

  1. Newsgroups: comp.lang.c++
  2. Path: sparky!uunet!zaphod.mps.ohio-state.edu!magnus.acs.ohio-state.edu!usenet.ins.cwru.edu!po.CWRU.Edu!exk11
  3. From: exk11@po.CWRU.Edu (Erik Kangas)
  4. Subject: ".", "->" operators and member data declarations
  5. Message-ID: <1992Jul21.141038.20704@usenet.ins.cwru.edu>
  6. Sender: news@usenet.ins.cwru.edu
  7. Nntp-Posting-Host: cwns1.ins.cwru.edu
  8. Reply-To: exk11@po.CWRU.Edu (Erik Kangas)
  9. Organization: Case Western Reserve University, Cleveland, OH (USA)
  10. Date: Tue, 21 Jul 92 14:10:38 GMT
  11. Lines:       40
  12.  
  13.  
  14.    I'm writing a memory management class in borland c++ that has
  15. access to XMS, EMS and VDISK memory and handles it transparently
  16. with conventional memory via handles.
  17.    However, To handle structures in memory, I currently have to 
  18. set up a number of constants relating to the byte offsets of the
  19. data in the structure.  Then add the byte offset to the handle using
  20. an overloaded "+" operator like so...
  21.  
  22. #define i 0
  23. #define x 4
  24.  
  25. struct foo {
  26.     long ident;
  27.     char xfer;
  28.     };
  29.  
  30. .....
  31.  
  32. Handle Fooptr = Malloc(sizeof(foo));
  33.  
  34. Fooptr + x = "P";
  35.  
  36. ......
  37.  
  38.     I would like to use some operator, ( I know "." is reserved and  "->"
  39. only returns a pointer to the structure.) that would know the offset of
  40. "xfer" in structure foo without me having to declare all the defines.
  41. I should be able to do a "Fooptr.xfer = "P"".
  42.     Does anyone know of a built in way of transferring these offset values
  43. and how I could tie them into overloaded operators?
  44.  
  45. Thank you.
  46.  
  47. -- 
  48. Erik Kangas  
  49. Physics/Math/CompE         "I lift up mine eyes unto the hills whence  
  50. Phone 754-2316              cometh my strength"  Psalms                
  51. Zeta Psi #304               Whereof we cannot speak, Thereof we must be silent.
  52.