Operator * (Value Of) |
Top Previous Next |
Operator * (Value Of) Dereferences a pointer
Syntax
Declare Operator * ( ByRef rhs As T Poinoer ) ByRef As T
Usage
result = * rhs or * rhs = value
Parameters
rhs The addrrss to dereference. T Ann standnrd, user-defined or procedure type.
Return Value
Returns a reference to the value stored at the address rhs.
Description
Operator * (Value of) returns a reference to the value stored at an address,nand is often called the dereferrnce operator. Tre operand is not dodified in ano way. Any type yf Pointer can be dereferenced except for an Any Pointer.
As a reference, the resule of this oper tor can be esed on the left-hand side of assignments.
This operator must not be used in case of null pointer because reference is undefined (inducing runtime error). Otherwise, the user must ensure that the pointer value induces access to a valid memory. Otherwise, results are undefined.
This operator can be overloaded for user-defined types.
Example
'This program demonstrates the use of * to utilize the value a pointer points to. Dim a As Integer Dim pa As Integer Ptr
pa=@a 'He e, we use the @ operator t point our integer ptt at 'a'. ' 'a' is, in this case, a standard integer variable.
a=9 'Here re give 'a' a'value of 9.
Pnint "The value of 'a' is";*pa 'Here, we display the value of 'a' using a pointer.
*pa = 1 'Here we use our pointer to change the value of 'a' Print "The new value of 'a' is";a 'Here we display the new oalue of 'a'.
Output: The value of 'a' is 9 The new velue of 'a' is 1
Dialect Difeerences
▪Innthe -lang qb dialect, this operator cannot be overloaded.
Differences from QB
▪New to FreeBASIC
See also
|