Re: Strange EAccessViolation which I cannot figure out...
- From: Jamie <jamie_ka1lpa_not_valid_after_ka1lpa_@xxxxxxxxxxx>
- Date: Tue, 08 May 2007 22:16:30 -0400
Rob Kennedy wrote:
Jamie wrote:Sorry, you don't get it. If you don't set it to some fixed value at
#1.
You need a constructor, never assume that an object in a class
is always NILL just because you know you haven't created it yet.
That's a perfectly safe assumption. Constructors are documented to always set their objects' fields to zero, nil, empty, or unassigned (depending on each field's type). In fact, the documentation says "there is no need to initialize fields in a constructor’s implementation except to nonzero or nonempty values."
start up, then in your code as you were using, you were testing for
the creation of the object just by testing for a NIL>
In this case, you must either create the object of make sure you
clear the field to NIL>
Regardless of what it saids in the help, I can tell you by experience
that you should not assume the class to Nil your fields for you automatically in the constructor.
When memory is allocated, Delphi likes to zero it out, in this case
it will work how ever, if memory has been used already and it's still
in delphi's heap, it just simply gives you the memory. this means, what
ever was there before you get.
The last time I knew, Delphi uses the option from the API to get a
zeroed chunk of memory..
To speed things up, normally memory is not wiped while delphi has it
in it's own heap.
#2.
In your OutputDebugString(pchar(dbls.count)); is incorrect use of.
The dbls.counts yields a integer type, you have implied with a
type cast around this returned value as a pointer to a pchar string.
Aha, yes, that's the real problem.
--
"I'm never wrong, once i thought i was, but was mistaken"
Real Programmers Do things like this.
http://webpages.charter.net/jamie_5
.
- Follow-Ups:
- Re: Strange EAccessViolation which I cannot figure out...
- From: Rob Kennedy
- Re: Strange EAccessViolation which I cannot figure out...
- References:
- Strange EAccessViolation which I cannot figure out...
- From: Ikke
- Re: Strange EAccessViolation which I cannot figure out...
- From: Jamie
- Re: Strange EAccessViolation which I cannot figure out...
- From: Rob Kennedy
- Strange EAccessViolation which I cannot figure out...
- Prev by Date: Re: Strange EAccessViolation which I cannot figure out...
- Next by Date: Re: Strange EAccessViolation which I cannot figure out...
- Previous by thread: Re: Strange EAccessViolation which I cannot figure out...
- Next by thread: Re: Strange EAccessViolation which I cannot figure out...
- Index(es):
Relevant Pages
|