我是C ++领域的新手,面对双重指针。问题是如何在函数x=5
中设置test
?
#include <iostream>
using namespace std;
typedef struct _DoublePointer
{
int x;
int y;
} DoublePointer;
void test(_DoublePointer** pointer)
{
}
void main()
{
_DoublePointer* pointer = new _DoublePointer;
_DoublePointer** doublePointer = &pointer;
test(doublePointer);
}
答案 0 :(得分:6)
做到这一点的方式是
(*pointer)->x = 5;