Contachit
Declare 'view pointer' variable of built-in data type.
Source code for objects 'Robot' and 'Positronic_Brain', which live in namespace 'abc'.
Valid uses of a 'view pointer'.
Why all these restrictions?
-
Why would a "view pointer" need to refer to a "pointer"? Just use the "pointer" variable, even when passing as argument
that accepts a "view pointer" variable.
- A "local view pointer", has no reason to refer to a formal parameter, as you can just use the formal parameter variable.
- Basically, a lot of these restrictions are based on forced code simplicity.
-
The whole purpose of the "view pointer", is to have a pointer that you know does NOT "own" the memory it refers to. For example, this
allows an object which has a "pointer" variable (which owns it's memory) to be able to return it from one of it's methods (as a "view pointer"), and
the variable on the receiving end of the method call knows they don't own the memory.
© 2023 Isaac Benson Powell