Board index » delphi » Pointer references

Pointer references

Could someone explain the different meanings for these pointer
references.  If you know of any books or articles that would explain
in detail the use of pointers within Object Pascal that would also be
helpful.

Pl^
Pl^.Siblings^
Results[1].Data^
Results^[1]

Thanks in advance.

A. Pantekoek

 

Re:Pointer references


Quote
antho...@magi.com (Anthony Pantekoek) wrote:
>Could someone explain the different meanings for these pointer
>references.  If you know of any books or articles that would explain
>in detail the use of pointers within Object Pascal that would also be
>helpful.
>Pl^

PI is a pointer to something.  This construct references the something
(as oppsed to PI itself, a pointer to a something).

Quote
>Pl^.Siblings^

PI is a pointer to a something, and that something is a record or a
class which contains a member which is a pointer to an
anothersomething.  This construct references the anothersomething.

Quote
>Results[1].Data^

Results is an array of records, each record of a type that contains a
pointer to  a something.  This references the something pointed to by
the pointer in the record stored in array position 1.

Quote
>Results^[1]

Results is a pointer to an array of somethings.  This references the
something at position 1 of the array.

Quote
>Thanks in advance.
>A. Pantekoek

------------------------------
Tim Shea
City Software, Inc.
c...@citysoft.com
Hit any key to continue, any other to exit.

Re:Pointer references


In article <4ofbqf$...@news.istar.ca>
           antho...@magi.com "Anthony Pantekoek" writes:

Quote
> Could someone explain the different meanings for these pointer
> references.  If you know of any books or articles that would explain
> in detail the use of pointers within Object Pascal that would also be
> helpful.

> Pl^

Value pointed to by Pl

Quote
> Pl^.Siblings^

Value pointed to by Siblings, within the object / record pointed to by Pl

Quote
> Results[1].Data^

Value pointed to by object 1 (in array results) 's member - Data

Quote
> Results^[1]

Array offset [1], where array is pointed to by Results

Hope This Helps

--
Daniel Silverstone

Re:Pointer references


In article <4ofbqf$...@news.istar.ca>,
   antho...@magi.com (Anthony Pantekoek) wrote:

Quote
>Could someone explain the different meanings for these pointer
>references.  If you know of any books or articles that would explain
>in detail the use of pointers within Object Pascal that would also be
>helpful.

>Pl^

This dereferences a pointer to something called P1.

Quote
>Pl^.Siblings^

This dereferences a pointer to siblings. siblings is a pointer varible in a
record that P1 is pointing to.

Quote
>Results[1].Data^

This is an array of records with one of the members being a pointer called
Data. This dereferences that pointer.

Quote
>Results^[1]

Results is an array that has been allocated on the heap. This points to index
1 of that array.

-----------------------------------------------
Mike Chapin
Powder River
mcha...@vcn.com
http://www.vcn.com/server/netizens/mchapin/first.html
Gillette, WY

Not the end of the earth but you can see it from
there.
-----------------------------------------------

Re:Pointer references


I will try to help, I think what I will say is correct

First, all of these are dereferencing the pointer

Pl^  -->In this case p1 is the whole pointer.  You could say
        p1:= 'Test'; {Providing it is a pointer to a string}

Pl^.Siblings^  -->  In this case p1 is a pointer to a record.  Siblings
                    is also a pointer.

type mypointer = ^Ppointer;
Ppointer = Record
        Siblings :Pointer;
End;

Var
    p1: MyPointer;

Results[1].Data^  -->  I belive this would be an array of Pointers,
                       someone correct me here.

Results^[1]       -->  This could also be an array of pointers, or a
                       pointer to a packed char array, such as

type mypointer = ^Ppointer;
Ppointer = Packed Array [1..2048] Of Char;

Var
    Results: MyPointer;

Results^[1] would get your the first array element.

Hope this helps somewhat, someone let me know if i am wrong on any of
these.

Other Threads