VDM-10 Language Manual
VDM-10 Language Manual
VDM-10 Language Manual
Create successful ePaper yourself
Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.
<strong>VDM</strong>-<strong>10</strong> <strong>Language</strong> <strong>Manual</strong><br />
✡✝<br />
end B<br />
class C is subclass of A<br />
instance variables<br />
i: int := 3;<br />
end C<br />
class D is subclass of B,C<br />
operations<br />
GetValues: () ==> seq of int<br />
GetValues() ==<br />
return [<br />
A‘i, -- equal to 1<br />
B‘i, -- equal to 1 (A‘i)<br />
]<br />
end D<br />
C‘i, -- equal to 3<br />
j -- equal to 2 (A‘j)<br />
✆<br />
In the example objects of class D have 3 instance variables: A‘i, A‘j and C‘j. Note that<br />
objects of class D will have only one copy of the instance variables defined in class A even though<br />
this class is a common super class of both class B and C. Thus, in class D the names B‘j, C‘j,<br />
D‘j and j are all referring to the same variable, A‘j. It should also be noticed that the variable<br />
name i is ambiguous in class D as it refers to different variables in class B and class C.<br />
14.4 Interface and Availability of Class Members<br />
In <strong>VDM</strong>++ and <strong>VDM</strong>-RT definitions inside a class are distinguished between:<br />
Class attribute: an attribute of a class for which there exists exactly one incarnation no matter<br />
how many instances (possibly zero) of the class may eventually be created. Class attributes<br />
in <strong>VDM</strong>++ and <strong>VDM</strong>-RT correspond to static class members in languages like<br />
C++ and Java. Class (static) attributes can be referenced by prefixing the name of the attribute<br />
with the name of the class followed by a ‘-sign (back-quote), so that, for example,<br />
ClassName‘val refers to the value val defined in class ClassName.<br />
Instance attribute: an attribute for which there exists one incarnation for each instance of the<br />
class. Thus, an instance attribute is only available in an object and each object has its own<br />
copy of its instance attributes. Instance (non-static) attributes can be referenced by prefixing<br />
the name of the attribute with the name of the object followed by a dot, so that, for example,<br />
object.op() invokes the operation op in the object denoted by object (provided that<br />
op is visible to object).<br />
132