从包中调用“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.
更多推荐
发布评论