18.10.2014 Views

Object-oriented Software in Ada 95

Object-oriented Software in Ada 95

Object-oriented Software in Ada 95

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Exceptions 177<br />

12.3.1 Overload<strong>in</strong>g = and /=<br />

The operators = and /= are provided automatically by the <strong>Ada</strong> system for compar<strong>in</strong>g for equality or not equality.<br />

However, if a user redef<strong>in</strong>es the = operator with a function that returns a Boolean value, the <strong>Ada</strong> system<br />

automatically provides the def<strong>in</strong>ition of /= as simply not =.<br />

If the operator = is overloaded by a function that returns a value other than a Boolean, then the user must<br />

explicitly provide an overload def<strong>in</strong>ition for /= if it is to be used.<br />

12.3.2 Specification of the class Bounded_Str<strong>in</strong>g<br />

The <strong>Ada</strong> specification of the class Bounded_Str<strong>in</strong>g is shown below:<br />

package Class_Bounded_Str<strong>in</strong>g is<br />

type Bounded_Str<strong>in</strong>g is private;<br />

function To_Bounded_Str<strong>in</strong>g(Str:<strong>in</strong> Str<strong>in</strong>g)<br />

return Bounded_Str<strong>in</strong>g;<br />

function To_Str<strong>in</strong>g(The:<strong>in</strong> Bounded_Str<strong>in</strong>g) return Str<strong>in</strong>g;<br />

function "&" (F:<strong>in</strong> Bounded_Str<strong>in</strong>g; S:<strong>in</strong> Bounded_Str<strong>in</strong>g)<br />

return Bounded_Str<strong>in</strong>g;<br />

function "&" (F:<strong>in</strong> Bounded_Str<strong>in</strong>g; S:<strong>in</strong> Str<strong>in</strong>g)<br />

return Bounded_Str<strong>in</strong>g;<br />

function "&" (F:<strong>in</strong> Str<strong>in</strong>g; S:<strong>in</strong> Bounded_Str<strong>in</strong>g)<br />

return Bounded_Str<strong>in</strong>g;<br />

function Slice( The:<strong>in</strong> Bounded_Str<strong>in</strong>g;<br />

Low:<strong>in</strong> Positive; High:<strong>in</strong> Natural )<br />

return Str<strong>in</strong>g;<br />

function "=" ( F:<strong>in</strong> Bounded_Str<strong>in</strong>g; S:<strong>in</strong> Bounded_Str<strong>in</strong>g )<br />

return Boolean;<br />

function ">" ( F:<strong>in</strong> Bounded_Str<strong>in</strong>g; S:<strong>in</strong> Bounded_Str<strong>in</strong>g )<br />

return Boolean;<br />

function ">=" ( F:<strong>in</strong> Bounded_Str<strong>in</strong>g; S:<strong>in</strong> Bounded_Str<strong>in</strong>g )<br />

return Boolean;<br />

function "

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!