放弃指针
语法
用法
result = * rhs
参数
返回值
返回对存储在地址rhs 的值的引用。
说明
操作符 *(值)返回对存储在地址中的值的引用,通常称为取消引用运算符。操作数不会以任何方式进行修改。
作为参考,该操作符的结果可以在赋值的左侧使用。
对于用户定义的类型,此运算符可能会重载。
例子
'该程序演示了使用*来使用指针指向的值。
Dim a As Integer
Dim pa As Integer Ptr
pa=@a 'Here, we use the @ operator to point our integer ptr at 'a'.
' 'a'在这种情况下,是一个标准的整数变量。
a=9 'Here we give 'a'值9。
Print "'a'的值是";*pa 'Here, we display the value of 'a'使用指针。
*pa = 1 'Here we use our pointer to change the value of 'a'
Print "“a”的新价值是";a 'Here we display the new value of 'a'.
输出:
The value of 'a' is 9
The new value of 'a' is 1
方言差异
与QB差别
参考