Anonymous user
Function prototype: Difference between revisions
Demonstrate packages
m (omissions) |
(Demonstrate packages) |
||
Line 14:
=={{header|Ada}}==
In Ada, prototypes are called specifications.
*
* All specifications must appear in a declarative section, ie: before a "begin" statement.
* For a main program,
* For a
<lang Ada>function noargs return Integer;
function twoargs (a, b : Integer) return Integer;
Line 30 ⟶ 31:
next : accBox; -- including that a box holds access to other boxes
end record;</lang>
Example of a package specification (i.e. prototype).:
<lang Ada>
package Stack is
procedure Push(Object:Integer);
function Pull return Integer;
end Stack;
</lang>
Example of a package body:
<lang Ada>
package body Stack is
procedure Push(Object:Integer) is
begin
-- implementation goes here
end;
function Pull return Integer;
begin
-- implementation goes here
end;
end Stack;
</lang>
To use the package and function
<lang Ada>
with Stack;
procedure Main is
N:integer:=5;
begin
Push(N);
...
N := Pull;
end Main;
</lang>
=={{header|C}}==
|