gpt4 book ai didi

compiler-errors - "Declaration of full view must appear in private part"的解释

转载 作者:行者123 更新时间:2023-12-02 10:49:22 25 4
gpt4 key购买 nike

我收到一个错误,我找不到任何文档来解释我的代码中需要修复的内容。代码是:

   type BinarySearchTreePoint is limited private;
type Node;
type BinarySearchTreePoint is access Node;

type Node is
record
Llink, Rlink : BinarySearchTreePoint;
Ltag, Rtag : Boolean; --True indicates pointer to lower level,
-- False a thread.
Info : Customer;
end record;

我得到的错误是 declaration of full view must appear in private part .它抛出这个错误指向行 type BinarySearchTreePoint is access Node; ,我不确定错误消息的含义。

最佳答案

当你说 type Foo is private; (或 limited private )您需要在私有(private)部分提供完整的声明;当然,这意味着您必须拥有私有(private)部分。

您显示的代码将编译

package Foo is
type BinarySearchTreePoint is limited private;
private
type Node;
type BinarySearchTreePoint is access Node;

type Node is
record
Llink, Rlink : BinarySearchTreePoint;
...

但如果你需要 Node要在包裹外可见,您需要说类似的话

package Foo is
type BinarySearchTreePoint is limited private;
type Node is private;
-- stuff to do with getting a Node from a BinarySearchTreePoint??
function Content (Of_Node : Node) return Customer;
private
type BinarySearchTreePoint is access Node;

type Node is
record
Llink, Rlink : BinarySearchTreePoint;
...

关于compiler-errors - "Declaration of full view must appear in private part"的解释,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40698850/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com