Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 Why Pointers
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
Danjen




PostPosted: Tue Dec 12, 2006 10:44 pm   Post subject: Why Pointers

In what situation would you use pointers and what are they? As far as I can tell, they are just used to check the next value in a sequence. Confused
Sponsor
Sponsor
Sponsor
sponsor
ericfourfour




PostPosted: Tue Dec 12, 2006 10:50 pm   Post subject: (No subject)

When dealing with variables, why send an entire copy of a variable if you only need a reference to its location?
Danjen




PostPosted: Tue Dec 12, 2006 10:56 pm   Post subject: (No subject)

So like, it lets you get the value of a variable without typing in that variable's specific name??
ericfourfour




PostPosted: Tue Dec 12, 2006 11:08 pm   Post subject: (No subject)

If you want to be simple, I guess that sums it up.

In Turing you can dereference but you cannot reference. That is one of the downsides of Turing. Sad There is a function called addr but it returns the address as an integer, not a pointer.

Dereference gets the variable the pointer is pointing to. Reference gets a pointer pointing to the variable.

To dereference use:
code:
^pointer_name


A pointer inside a record:
code:
^ (record_name.pointer_name)
Danjen




PostPosted: Wed Dec 13, 2006 9:13 am   Post subject: (No subject)

Ah, okay that clears it up then Smile
Tony




PostPosted: Wed Dec 13, 2006 11:45 am   Post subject: (No subject)

Danjen wrote:
So like, it lets you get the value of a variable without typing in that variable's specific name??


Better yet, you can switch where the pointer points to, and perform the same operations on a different "variable", without really needing to know which one exactly it is.
Latest from compsci.ca/blog: Tony's programming blog. DWITE - a programming contest.
Display posts from previous:   
   Index -> Programming, Turing -> Turing Help
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 6 Posts ]
Jump to:   


Style:  
Search: