main()
{
int *a;
myfunc(a);
}
myfunc(int & *b)
{
//'b' is a pointer with the same address as 'a'
//so if you change what 'b' points to, it also changes what 'a' points to
}
Run Code Online (Sandbox Code Playgroud)
以上是行不通的。现在这没什么大不了的,因为你可以使用双指针来做同样的事情,拥有引用指针似乎更简单。
main()
{
int *a;
myfunc(&a)
}
myfunc(int **b)
{
//de-referencing b once will give you the 'a' pointer
}
Run Code Online (Sandbox Code Playgroud) c++ ×1