home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.lang.c++
- Path: sparky!uunet!zaphod.mps.ohio-state.edu!magnus.acs.ohio-state.edu!usenet.ins.cwru.edu!po.CWRU.Edu!exk11
- From: exk11@po.CWRU.Edu (Erik Kangas)
- Subject: ".", "->" operators and member data declarations
- Message-ID: <1992Jul21.141038.20704@usenet.ins.cwru.edu>
- Sender: news@usenet.ins.cwru.edu
- Nntp-Posting-Host: cwns1.ins.cwru.edu
- Reply-To: exk11@po.CWRU.Edu (Erik Kangas)
- Organization: Case Western Reserve University, Cleveland, OH (USA)
- Date: Tue, 21 Jul 92 14:10:38 GMT
- Lines: 40
-
-
- I'm writing a memory management class in borland c++ that has
- access to XMS, EMS and VDISK memory and handles it transparently
- with conventional memory via handles.
- However, To handle structures in memory, I currently have to
- set up a number of constants relating to the byte offsets of the
- data in the structure. Then add the byte offset to the handle using
- an overloaded "+" operator like so...
-
- #define i 0
- #define x 4
-
- struct foo {
- long ident;
- char xfer;
- };
-
- .....
-
- Handle Fooptr = Malloc(sizeof(foo));
-
- Fooptr + x = "P";
-
- ......
-
- I would like to use some operator, ( I know "." is reserved and "->"
- only returns a pointer to the structure.) that would know the offset of
- "xfer" in structure foo without me having to declare all the defines.
- I should be able to do a "Fooptr.xfer = "P"".
- Does anyone know of a built in way of transferring these offset values
- and how I could tie them into overloaded operators?
-
- Thank you.
-
- --
- Erik Kangas
- Physics/Math/CompE "I lift up mine eyes unto the hills whence
- Phone 754-2316 cometh my strength" Psalms
- Zeta Psi #304 Whereof we cannot speak, Thereof we must be silent.
-