 |
BorlandTalk.com Borland discussion newsgroups
|
| View previous topic :: View next topic |
| Author |
Message |
Talts Guest
|
Posted: Sun Feb 18, 2007 9:01 pm Post subject: Accessing members through pointer |
|
|
Hi,
I am relatively new to Delphi, and have a basic question regarding
handling pointers.
Assume that I have a pointer to a record pR, and wish to access one of
its members (e.g. mem1), how do I do that?
Does it work with both ways: pR^.mem1 and pR.mem1 ?
(It seems to be compiled and ran ok in both ways)
If so, for what purpose do we need "^", except when declaring the
pointer type itself.
Thanks,
Tal. |
|
| Back to top |
|
 |
DEV-il Guest
|
Posted: Mon Feb 19, 2007 9:10 am Post subject: Re: Accessing members through pointer |
|
|
On Feb 18, 4:01 pm, "Talts" <zur....@gmail.com> wrote:
| Quote: | Hi,
I am relatively new to Delphi, and have a basic question regarding
handling pointers.
Assume that I have a pointer to a record pR, and wish to access one of
its members (e.g. mem1), how do I do that?
Does it work with both ways: pR^.mem1 and pR.mem1 ?
(It seems to be compiled and ran ok in both ways)
If so, for what purpose do we need "^", except when declaring the
pointer type itself.
Thanks,
Tal.
|
Hi Tal,
For what I know the "^" symbol stands for "content of the cell wich
the pointer type points to"... That is, the data pointed by the
pointer variable.
If I remember well, in older versions of Delphi, if you didn't use the
"^" you would not get your source compiled.
Since some time, for sure in Delphi 7, you can reference your data
with or without the "^".
The compiler itself will resolve the reference.
In few words, you can still keep on using "Pointer^.Member" or
"Pointer.Member".
Personally, I prefer to use "Pointer^.Member" style, becuase it
remembers me that I'm dealing with pointers and that somehow /
somewhere I will have to free the pointer variable with a Dispose.
DEV-il |
|
| Back to top |
|
 |
Powered by phpBB © 2001, 2006 phpBB Group .
|