2012-04-03 56 views
1

我使用Ada.Containers.Indefinite_Vectors实现载体的属性,但每当我做这样的事情:无法正常访问私有类型

size := myVector'Length; 

我得到这个错误:

prefix for "Length" attribute may not be private type 

如何访问此属性?

回答

6

Ada.Containers.Indefinite_Vectors定义了获取长度的函数。它被称为Length

所以,在你的代码:

size := myVector.Length; -- Ada 2005/2012 
size := myVectorPackage.Length (myVector); -- Ada 95 

属性'Length仅适用于数组类型。

+0

啊,愚蠢的我。我整个时间都在误读指令。我想我只是需要另一双眼睛。谢谢。 – 2012-04-03 12:29:59