Ada ...从主程序看不到程序

问题描述

我刚从Ada开始,却很难弄清楚。

我有main.adb,createlist.adb和createlist.ads(后面的代码

我遇到了错误

“ print_list”不可见(更多参考文献随后出现)

createlist.ads中的不可见声明:(无论行号)

每个过程和功能

我尝试过在main内部不进行所有操作,并且在那里可以正常工作,所以我已经知道这些程序在可见时会执行它们应做的事情。我只是不确定自己在做什么,使它们不可见。我遍历了所有的课堂笔记,包括google,github,此处和其他各种论坛,但都没有找到解决方案。

main.adb

with Ada.Text_IO;
use Ada.Text_IO;
with Ada.Float_Text_IO;
use Ada.Float_Text_IO;
with CreateList;



procedure Main is

   max: integer;
   pointer: integer;
   len: integer;

   package IntIO is new Ada.Text_IO.Integer_IO(Integer); use IntIO;

begin

   Put("What size is the array? ");
   get(max);

      declare

      list: array (1 .. max) of Integer;

   begin
      list := (others => 0);
      pointer := 0;
      len := 0;

      print_list;
      add_to_list(12);
      add_to_list(3);
      add_to_list(7);
      print_list;
      len := length_of_list;
      for pointer in 1 .. len loop
         print_list;
      end loop;
      Put_Line("");
      delete_from_list(2);
      print_list;
   end;

end Main;

createlist.adb

with Ada.Text_IO;
use Ada.Text_IO;
with Ada.Float_Text_IO;
use Ada.Float_Text_IO;

package body CreateList is -- in file CreateList.adb
   len: Integer;
   list: array(1..max) of itemType;

   procedure add_to_list (ListItem: in itemType) is begin
      if pnt >= max then
            Put_Line("**Detected Overflow**");
         else
            pnt := pnt + 1;
            list(pnt) := ListItem;
         end if;
      null;
   end add_to_list;

   procedure delete_from_list (indx: in Integer) is begin
      if indx = 0 then
            Put_Line("**Detected Underflow**");
      else
         for j in indx .. (pnt - 1) loop
            if j < len then
               list(j) := list(j + 1);
            end if;
         end loop;

         pnt := pnt - 1;
      end if;
      null;
   end delete_from_list;

   function length_of_list return Integer is begin
      return len;
   end length_of_list;

   procedure print_list (indx: in Integer) is begin
      Put(list(indx));
      Put(" ");
      null;
   end print_list;

   procedure print_list is begin
      for i in 1 .. max loop
         Put(list(i));
         Put(" ");
      end loop;
      Put_Line("");
      null;
   end print_list;

end CreateList;

createlist.ads

generic
   max: integer;
   type itemType is private;

package CreateList is
      
   procedure add_to_list (listItem: in itemType);
   --   
   procedure delete_from_list (indx: in itemType);
   --   
   function length_of_list return itemType;
   --
   procedure print_list (indx: in itemType);
   procedure print_list;

end CreateList;

我也很难传递指针。

谢谢您的帮助。

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)