comp.lang.ada
 help / color / mirror / Atom feed
* Generic Types and Packages in Ada, C++ , Java
@ 1997-02-26  0:00 EMANUELE COSTA
  0 siblings, 0 replies; only message in thread
From: EMANUELE COSTA @ 1997-02-26  0:00 UTC (permalink / raw)



Hi all,
        If there is something I really like about Ada are the generic
packages, but now I have to write some stuff in C++ and Java and so I would
like to know if there is  such a thing in these languages.
Example:

assuming a Generic Stack

-----
generic
        type object_type is private;
        max_size        :natural:=100;

package stack_package is

        stack_full      :exception;
        stack_empty     :exception;

        procedure push(the_Object       :object_type);

        function pop return object_type;

        function number_of_objects return natural;

end stack_package;


package body stack_package is

        subtype count is natural range 0..max_size;
        subtype index is positive range 1..max_size;
        type array_of_objects is array (index) of object_type;

        latest          :count:=0;
        objects         :array_of_objects;

        procedure push(the_object       :object_type) is
        begin
                latest:=latest+1;
                Objects(latest):=the_object;
        exception
        ...
        ...


finally in order to create an instance
e.g. stack of integers

package stack_1 is new stack_package(integer,50)

-----

COuld anyone mail two similar packages in C++ and Ada?
Thank you
                EMANUELE


--
e-mail: costa@unix.lancs.ac.uk
Jenkinson's Law: It Won't Work.
Support your local rescue centre: GET LOST!
SUPPORT 'PADANIA LIBERA' CAMPAIGN: www.leganordsen.it




^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~1997-02-26  0:00 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1997-02-26  0:00 Generic Types and Packages in Ada, C++ , Java EMANUELE COSTA

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox