You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Jacob Misirian edited this page Aug 25, 2016
·
1 revision
Hassium has the concept of pointers, similar to languages such as C, C++, and C#. A pointer is an object type that holds the variable in question and the stack frame in which it was created. It allows for a variable to be passed around, assigned to, and the value will be changed in any function which holds the pointer.
1. Creating Pointers
A pointer can be created from any variable using the & reference unary operator. This will return a pointer object that can then be passed around. An example would be as follows:
funcmain () {
a=45;
b=&a;
}
a still holds the value 45, but b is now of type pointer and holds a reference to a.
2. Accessing Pointers
A pointer object can be dereferenced, meaning the value be accessed and returned from the pointer so that it can be examined. This uses the * dereference unary operator like so:
The value referenced by the pointer can be modified once again by using the dereference operator on the left hand side of the assignment operator. Here is an example: