Mail Archives: djgpp/1999/01/08/04:26:55
From: | e9462 AT tc DOT hsa DOT nl (H.N. Oudejans)
|
Newsgroups: | comp.os.msdos.djgpp
|
Subject: | Pointer Problem
|
Date: | 8 Jan 1999 09:17:13 +0100
|
Organization: | Hogeschool Alkmaar, The Netherlands.
|
Lines: | 31
|
Distribution: | all
|
Message-ID: | <774eu9$d6o$1@mimas.tc.hsa.nl>
|
NNTP-Posting-Host: | mimas.tc.hsa.nl
|
X-Trace: | metis.hsa.nl 915783433 16905 194.171.19.170 (8 Jan 1999 08:17:13 GMT)
|
X-Complaints-To: | usenet AT hsa DOT nl
|
NNTP-Posting-Date: | 8 Jan 1999 08:17:13 GMT
|
Summary: | Pointer doesn't stay at the right value
|
Keywords: | Polymorph,Pointers
|
X-Newsreader: | NN version 6.5.1 (NOV)
|
To: | djgpp AT delorie DOT com
|
DJ-Gateway: | from newsgroup comp.os.msdos.djgpp
|
Reply-To: | djgpp AT delorie DOT com
|
My name is Herman Oudejans and I got a big problem with pointers.
When I init a variable Ptr_Button,and then call a function, then the pointer is changed as (a result of polymorphy) ?!?
Here's some code to explain it a bit further:
Ptr_Button=new Button (.....)
AddGadget (InfoButton)
void AddGetget (Object * object) // Object is a parent of Button
In a debugger (rhide) ,the result is as follows
Ptr_Button (Button *) 0xa17055 // or some other address
object (Object *) 0xa17078
The pointer points to the same object, so I can't delete Ptr_Button without destroying object as well. (Maybe because object is just a local).
The meaning of this all is to keep the pointer in a pointer-linked-list so I can safely delete it, but since the pointer is different delele won't work.
Can anybody help me to
1) solve this problem
2) maybe help me to some code for some sort of collection object (a pointer-linked-list with polymorph items)
Thanks in advance
- Raw text -