请看下面的代码
#include <iostream>
using namespace std;
int main()
{
int a = 5;
int *aPtr1 = &a;
int *aPtr2 = aPtr1;
int *aPtr3 = aPtr2;
cout << "'a' value: " << a << endl;
cout << "'aPtr1' value: " << *aPtr1 << endl;
cout << "'aPtr2' value: " << *aPtr2 << endl;
cout << "'aPtr2' value from 'aPtr3': " << **aPtr3 << endl;
}
在这里,在最后一行,我试图从“aPtr3”中获取“aPtr2”值。换句话说,这是我试图找到“之前的指针”。但它给了我错误
PointerTest.cpp:16: error: invalid type argument of `unary *'
我怎样才能做到这一点?请帮忙!