从包中调用“Ada.float

编程入门 行业动态 更新时间:2024-10-27 02:24:07
包中调用“Ada.float_text_IO.get”以从控制台读取用户输入(Calling “Ada.float_text_IO.get” from a package to read user input from the console)

我想在主文件创建的包文件中使用Ada.float_text_IO.Get :( .adb)&(。ads),使用以下过程从控制台读取用户输入:

procedure Get(Item : out Num; Width : in Field := 0);

在任何地方都没有例子。 救命 :)

I want to use Ada.float_text_IO.Get , in a packagefile created : (.adb)&(.ads) from a mainfile to read user input from the console using the procedure:

procedure Get(Item : out Num; Width : in Field := 0);

There is no example anywhere . Help :)

最满意答案

有两种选择:包装程序或重命名它。

with Ada.Text_IO;
with Ada.Float_Text_IO;

procedure Main is

   package My_Float_Text_IO is
      procedure Get_1 (Item : out Float; Width : Ada.Text_IO.Field := 0);
      procedure Get_2 (Item : out Float; Width : Ada.Text_IO.Field := 0) renames Ada.Float_Text_IO.Get;
   end;

   package body My_Float_Text_IO is
      procedure Get_1 (Item : out Float; Width : Ada.Text_IO.Field := 0) is
      begin
          Ada.Float_Text_IO.Get (Item, Width);
      end;
   end;

   F : Float;

begin

   My_Float_Text_IO.Get_1 (F);
   My_Float_Text_IO.Get_2 (F);

end;
 

将规范代码放入.ads文件和body cody(实现代码)到.adb文件中。 您也可以在没有包的情况下将一个过程或函数放在.ads和.adb文件中。 你也可以有一个没有身体包的规格包。

There are two alternatives: wrap the procedure or rename it.

with Ada.Text_IO;
with Ada.Float_Text_IO;

procedure Main is

   package My_Float_Text_IO is
      procedure Get_1 (Item : out Float; Width : Ada.Text_IO.Field := 0);
      procedure Get_2 (Item : out Float; Width : Ada.Text_IO.Field := 0) renames Ada.Float_Text_IO.Get;
   end;

   package body My_Float_Text_IO is
      procedure Get_1 (Item : out Float; Width : Ada.Text_IO.Field := 0) is
      begin
          Ada.Float_Text_IO.Get (Item, Width);
      end;
   end;

   F : Float;

begin

   My_Float_Text_IO.Get_1 (F);
   My_Float_Text_IO.Get_2 (F);

end;
 

Put specification code into .ads files and body cody (implementation code) into .adb files. You can also just put one procedure or function in .ads and .adb file without package. You can also have a specification package without body package.

更多推荐

本文发布于:2023-08-04 23:21:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1423275.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:包中   Ada   float

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!