Computer Science Canada Why Pointers |
Author: | Danjen [ 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. ![]() |
Author: | ericfourfour [ Tue Dec 12, 2006 10:50 pm ] |
Post subject: | |
When dealing with variables, why send an entire copy of a variable if you only need a reference to its location? |
Author: | Danjen [ Tue Dec 12, 2006 10:56 pm ] |
Post subject: | |
So like, it lets you get the value of a variable without typing in that variable's specific name?? |
Author: | ericfourfour [ Tue Dec 12, 2006 11:08 pm ] | ||||
Post 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. ![]() Dereference gets the variable the pointer is pointing to. Reference gets a pointer pointing to the variable. To dereference use:
A pointer inside a record:
|
Author: | Danjen [ Wed Dec 13, 2006 9:13 am ] |
Post subject: | |
Ah, okay that clears it up then ![]() |
Author: | Tony [ Wed Dec 13, 2006 11:45 am ] |
Post 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. |
: |