2012-10-01 35 views
0

我试图使用Ada来打印从自然派生的类;但是,我不断收到错误,prefix of "image" attribute must be a type。 Google显然对这个错误一无所知。Ada:“图像”属性的前缀必须是一个类型

这里是产生这种错误的简化代码:我Layout

with Ada.Text_IO; 
use Ada.Text_IO; 
with Layout; use Layout; 
procedure temptest is 
    term : Terminator_ID; 
    begin 
     term := Layout.Block_GetOpposite (1, Layout.REVERSED); 
    Put_Line (Item => term'Image); 
    end temptest; 

这里是Terminator_ID定义:type Terminator_ID is new Natural range 1 .. 40;

是什么原因造成这个错误,什么是正确的适当方法它?

回答

2

显然,将数字转换为字符串的语法是Type_Name'Image(var_containing_value)

我改变了我的代码:

with Ada.Text_IO; 
use Ada.Text_IO; 
with Layout; use Layout; 
procedure temptest is 
    term : Terminator_ID; 
    begin 
     term := Layout.Block_GetOpposite (1, Layout.REVERSED); 
    Put_Line (Item => Terminator_ID'Image (term)); 
    end temptest; 

,它现在编译罚款。

+2

错误信息告诉你的究竟是什么。 –

+0

我被/写在问题中。 – weberc2

+0

对不起,我在我以前的评论中意外地遗漏了一个词。我的意思是写“哪个*正是错误信息告诉你的”。 –

相关问题