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

Explanation of "Declaration of full view must appear in private part"

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

   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)时,您需要在隐私部分提供完整的声明;当然,这意味着您必须 隐私部分。

您显示的代码将编译

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;
         ...