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

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Preface<br />

xix<br />

Instance<br />

attribute<br />

A data component conta<strong>in</strong>ed <strong>in</strong> an object. In <strong>Ada</strong> the data components are<br />

conta<strong>in</strong>ed <strong>in</strong> a record structure <strong>in</strong> the private part of the package.<br />

type Account is record<br />

Balance_Of : Money := 0.00; --Instance attribute<br />

end record;<br />

Instance method<br />

A procedure of function <strong>in</strong> a class that accesses the <strong>in</strong>stance attributes (data<br />

items) conta<strong>in</strong>ed <strong>in</strong> an object. For example, the method Balance accesses<br />

the <strong>in</strong>stance attribute Balance_Of.<br />

function Balance( The:<strong>in</strong> Account ) return Money is<br />

beg<strong>in</strong><br />

return The.Balance_Of;<br />

end Balance;<br />

Instantiation<br />

The act of creat<strong>in</strong>g a specific <strong>in</strong>stance of a generic unit. For example, the<br />

generic package Integer_Io <strong>in</strong> the package <strong>Ada</strong>.Text_Io can be<br />

<strong>in</strong>stantiated to deliver the package Pack_Mark_Io which performs I/O on<br />

the <strong>in</strong>teger type Exam_Mark as follows:<br />

type Exam_Mark is range 0 .. 100;<br />

package Pack_Mark_Io is new<br />

<strong>Ada</strong>.Text_Io.Integer_Io(Exam_Mark);<br />

Then a programmer can write<br />

Miranda : Exam_Mark;<br />

Pack_Mark_Io.Put( Miranda );<br />

to write the contents of the Integer object Miranda.<br />

Message<br />

The send<strong>in</strong>g of data values to a method that operates on an object. For<br />

example, the message 'deposit £30 <strong>in</strong> account Mike' is written <strong>in</strong> <strong>Ada</strong> as:<br />

Deposit( Mike, 30 );<br />

Note: The object to which the message is sent is the first parameter.<br />

Meta-class<br />

Method<br />

Multiple<br />

<strong>in</strong>heritance<br />

An <strong>in</strong>stance of a meta-class is a class. Meta-classes are not supported <strong>in</strong> <strong>Ada</strong>.<br />

Implements behaviour <strong>in</strong> an object. A method is implemented as a procedure<br />

or function <strong>in</strong> a class. A method may be either a class method or an <strong>in</strong>stance<br />

method.<br />

A class derived from more than one base class. Multiple <strong>in</strong>heritance is not<br />

directly supported <strong>in</strong> <strong>Ada</strong>.<br />

© M A Smith - May not be reproduced without permission

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

Saved successfully!

Ooh no, something went wrong!