Pointer: Difference between revisions
Lemonstale (talk | contribs) (Put into paragraph form, fixed some spelling) |
|||
Line 1: | Line 1: | ||
[[Category:Variables]] | [[Category:Variables]] | ||
'''Pointers''' are special in C++. '''Pointers''' can be used to point to a [[variable]] instead of becoming a variable. | '''Pointers''' are special in C++. '''Pointers''' can be used to point to a [[variable]] instead of becoming a variable. Here is an example: There are 5 [[integer]] [[variable]]s. Each one is named accordingly (anInteger1, anInteger2, ect). However we have a [[function]] that uses whatever [[integer]] the user chooses. | ||
Here is an example: | |||
There are 5 [[integer]] [[variable]]s. | |||
Each one is named accordingly (anInteger1, anInteger2, ect) | |||
However we have a [[function]] that uses whatever [[integer]] the user chooses. | |||
Enter '''pointer'''s. | Enter '''pointer'''s. | ||
When running the program, the user makes his choice to pick whatever [[integer]] he wants. | When running the program, the user makes his choice to pick whatever [[integer]] he wants. When that happens, the '''pointer''' is pointed toward that [[integer]]. Finally, whenever the user is ready, he will continue to the next stage, where a [[function]] is run to return the value of the [[integer]] he has chosen. | ||
When that happens, the '''pointer''' is pointed | |||
Finally, whenever the user is ready, he will continue to the next stage, where a [[function]] is run to return the value of the [[integer]] he has chosen. | |||
The function will automatically pick whatever [[integer]] we have the '''pointer''' aimed at. | The function will automatically pick whatever [[integer]] we have the '''pointer''' aimed at. |
Revision as of 22:17, 1 August 2005
Pointers are special in C++. Pointers can be used to point to a variable instead of becoming a variable. Here is an example: There are 5 integer variables. Each one is named accordingly (anInteger1, anInteger2, ect). However we have a function that uses whatever integer the user chooses.
Enter pointers.
When running the program, the user makes his choice to pick whatever integer he wants. When that happens, the pointer is pointed toward that integer. Finally, whenever the user is ready, he will continue to the next stage, where a function is run to return the value of the integer he has chosen.
The function will automatically pick whatever integer we have the pointer aimed at.
Pointers in Scripting
There are also pointers used in scripting. A few working pointers in the source engine:
- !player - The local player
- !activator - What entity caused the current entity to run it's output. (ie, Player breaks crate, so !activator points to the player.)
- !picker - The entity that the local player is looking at.