1
我有節點結構(它包含下一個相同結構的值)。JNA初始化空節點結構
struct Node {
Node *nextElem;
Element thisValue;
};
我想在函數中傳遞empty(null)node.ByReference來填充它。
// C++
Element element = ...; //fills in another function;
Node *list = NULL;
AddElementToList(element, &list);
// which declered as
void AddElementToList (Element element, Node * list) {...}
// Java
Element.ByValue element = ...; //fills great in another function in the same way ByReference (and reconstructed as ByValue),
//but initialize with trash in Pointers and without recurtion;
Node.ByReference list = null;
MyDll.INSTANCE.AddElementToList(element, list);
所以,如果我用
Node.ByReference list = null;
我得到無效的內存訪問錯誤當C++方面嘗試讀取列表,像任何空指針秒。 所以我想初始化列表。但在這種情況下,我必須初始化下一個節點和明年和...
你能展示C++函數的聲明是什麼,以及你將如何在C++中調用它? – cubrr
啊,但你似乎需要一個指向一個節點的空指針的指針。您當前正在傳遞空指針。 – cubrr
你確定AddElementToList不是'(Element element,Node ** list)'嗎? – cubrr