Ada: Understanding private types and understanding packaging

痴心易碎 提交于 2019-12-02 00:01:37

why do not I have to use the methods set_Horz(A) and set_Vert(A) prior to issuing the command

Because you're setting the fields of your private record by executing:

Rectangular_Form.Vector_Basis_r (A => Theta, D => Basis_r);

(Review the implementation of Vector_Basis_r.)

-- EXPANDED Answer

When you declare the Basis_r variable in your Test_Rectangular_Form procedure, the memory for that "Rectangular" variable is allocated. At this point the Horz and Vert fields in the private type are present, but unset (they could contain anything).

When you call Rectangular_Form.Vector_Basis_r, its implementation sets the values of those private fields. Maybe this is what's confusing you: the body of the package in which a private type is declared has direct access to those fields. This is exactly the aspect that Vector_Basis_r is exploiting when setting their values (as well as Set_Vert and Set_Horz).

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!