Ada supports methods defined on record types, which are similar to structs in other languages.
In Ada, we don’t have methods in the same way as in some object-oriented languages. Instead, we define functions that take the record as a parameter. This achieves a similar result to methods in other languages.
Ada doesn’t have the concept of receiver types in the same way. Instead, we pass the record as a parameter to our functions. The Area and Perim functions both take a Rect as their parameter.
Ada uses strong typing, so we don’t need to worry about automatic conversion between values and pointers. If we want to work with a reference to a record, we can use an access type (Ada’s version of pointers).
To run this program:
Next, we’ll look at Ada’s mechanism for grouping and naming related sets of operations: packages.