From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: * X-Spam-Status: No, score=1.4 required=5.0 tests=BAYES_50,INVALID_MSGID autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,142cb9c36059285e,start X-Google-Attributes: gid103376,public From: EMANUELE COSTA Subject: Generic Types and Packages in Ada, C++ , Java Date: 1997/02/26 Message-ID: #1/1 X-Deja-AN: 221647481 Sender: Ada programming language Comments: Gated by NETNEWS@AUVM.AMERICAN.EDU Newsgroups: comp.lang.ada Date: 1997-02-26T00:00:00+00:00 List-Id: 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