Repository navigation
Operator Value of
Home › Operators › Operator * (Value Of)
Dereferences a pointer
Declare Operator * ( ByRef rhs As T Pointer ) ByRef As TrhsT
Operator * (Value of) returns a reference to the value stored at an address, and is often called the dereference operator. The operand is not modified in any way.
Any type of Pointer can be dereferenced except for an Any Pointer.
As a reference, the result of this operator can be used 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.
Returns a reference to the value stored at the address rhs.
result = * rhs
or
* rhs = value- In the -lang qb dialect, this operator cannot be overloaded.
- New to FreeBASIC
'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 'Here, we use the @ operator to point our integer ptr at 'a'.
' 'a' is, in this case, a standard integer variable.
a=9 'Here we give 'a' a value of 9.
Print "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 value of 'a'.Output:
The value of 'a' is 9
The new value of 'a' is 1Category: Operators
Kind: operator
Reproduced from the FreeBASIC Wiki Manual under the GNU Free Documentation License 1.3 — with no Invariant Sections, no Front-Cover Texts and no Back-Cover Texts. Copyright © the FreeBASIC project and wiki contributors. See License.
tiko-lang · Home · Feature Index · Keyword Index · License
FreeBASIC manual pages reproduced under the GNU FDL 1.3.
- Generics
- Interfaces
- For Each
- Iterators
- Tuples
- Array Results
- Defer
- Lambdas
- Block Strings
- Partial Types
- String Slices
- Embed
- Typed Variadics
- C Header Import
- Foreign Library Linking
- UString
- Fixed-Width Types
- Nullptr
- String Library
- Format
- Array
- Map
- Set
- LinkedList
- OrderedMap
- OrderedSet
- Sorting
- Optional
- Result
- Smart Pointers
- Date and Time (Chrono)
- Filesystem
- File Streams
- Config (INI and TOML)
- Codec
- Hash
- UUID
- OS
- Process
- Net
- HTTP and TLS
- Math Library
- Finance
- Logging
- Terminal TUI Library
- PsControls
- tkControls
- sys/win
- Goroutines and Channels
- LLVM Backend
- tiko build
- TIKO_COMPILER
- Variable Declarations
- Standard Data Types
- User Defined Types
- Procedures
- Operators
- Control Flow Statements
- Converting Data Types
- Array Functions
- String Functions
- Mathematical Functions
- Bit Manipulation
- Date and Time Functions
- File I/O Functions
- Console Functions
- User Input (Runtime Library)
- User Input Functions (Graphics Library)
- Screen Functions
- 2D Drawing Functions
- Graphics Library Reference
- Graphics Keyword List
- Memory Functions
- Threading Support Functions
- Error Handling Functions
- Operating System Functions
- Preprocessor
- Intrinsic Defines
- Miscellaneous Keywords
- Modularizing