-1
由于无法创建引用(是否存在?)我必须使用指向另一个指针的指针来执行此操作。这给了我一个错误:Pascal指针指针SyntaxError和不兼容类型
type
PNode = ^TNode;
TNode = record
char: char;
next: PNode;
children: PNode;
end;
PPNode = ^PNode;
var
current_node: PPNode;
function find_or_insert_peer(var node: PNode; character: char): PNode;
current_node := @find_or_insert_peer(current_node^, character)^.children;
x.pas(121,23) Error: Incompatible types: got "<address of function(var PNode;Char):^TNode;Register>" expected "PPNode"
x.pas(121,43) Fatal: Syntax error, ";" expected but "(" found
Fatal: Compilation aborted
我也试过,但它并不能编译,因为的SyntaxError
current_node := @(find_or_insert_peer(current_node^, character)^.children);
编辑的
请帮助。我甚至用C++创建了一个演示来向你展示这是合法的。 http://cpp.sh/8mxe
为什么你认为在'current_node'赋值时需要@ @? – MartynA
你试图将'find_or_insert_peer'函数的地址分配给'PPNode',并且显然不起作用。实际上**在错误信息中读取单词**非常重要,它清楚地告诉您问题是什么以及两种类型之间为什么不兼容。 –
@KenWhite我做到了,这就是为什么我试图添加圆括号来强调我想要记录的地址(记录指针由函数返回)的属性。我只读了一个SyntaxError – Adam