2

我在结构中有一个指针。我将一个结构指针传递给这个指针。

但是我无法将类型转换回这个指向结构的指针。

public class Test
{

     //
     Pointer ptr = new Memory(4);
}

public class Temp extends Structure
{

     //

}

Test tst = new Test();
Temp tmp = new Temp();

tst.ptr = tmp.getPointer();

...

Temp newTmp = (Temp)tst.ptr.getPointer(); // This is not working.
4

1 回答 1

4

您需要使用构造函数创建一个投射到内存上的新结构Structure(Pointer p)

Temp newTmp = new Temp(tst.ptr.getPointer());
于 2010-08-22T15:31:51.653 回答