[Charset ISO-8859-1 unsupported, filtering to ASCII...]
> Hi all,
> I've been trying to debug some more. It turns out that both Field[0],
> Field[1] and Field[2] are pointing to the same objects. Which is the last
> TBStructure to be created. Does this mean this part of code doesn't create a
> New Object?
> Code:
> (*(Fields+numFields)) = TBStructure(string2int(tbP->X)
> ,string2int(tbP->Y)
>
> If that is the case how do I create a new instance of TBStructure?
Yes, that is probably it. You already created the objects when you did
the malloc in your earlier step. That didn't call the constructor,
however. This step doesn't call the constructor either. I'm not sure
what it *does* do (to be honest, now that I look at it, I'm kind of
surprised that it compiles), but whatever that is doesn't appear to be
what you want. What is the definition of your class?
If this were my code, I'd seriously consider rewriting it. What is it
that you're attempting to do with all of these dynamic textboxes? At
the very least, I'd think about changing things to have your "Fields"
array be an array of pointers to fields (this would then be what was
malloc'ed in your earlier routine), then have this section of code do
something like this:
Fields[numFields] = new TBStructure(string2int(tbP->X)
,string2int(tbP->Y),
string2int(tbP->Width),string2int(tbP->Height),
lastID++);
You should also arrange to have a loop after your processing is done
to delete these:
for (int kk=0; kk<numFieldsAlloc; kk++)
delete Fields[kk];
and then free the Fields array.
Dean
--
For information on using the PalmSource Developer Forums, or to unsubscribe,
please see http://www.palmos.com/dev/support/forums/