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=0.2 required=5.0 tests=BAYES_00,INVALID_MSGID, REPLYTO_WITHOUT_TO_CC autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,334540b5fc3dada1,start X-Google-Attributes: gid103376,public From: yus000@unbc.edu Subject: urgent help needed!!! Date: 1997/03/29 Message-ID: <859690935.9677@dejanews.com>#1/1 X-Deja-AN: 229367084 X-Http-User-Agent: Mozilla/3.0Gold (X11; I; SunOS 5.5 sun4m) X-Originating-IP-Addr: 142.207.113.84 (lib-162-4.lab.unbc.edu) Organization: Deja News Usenet Posting Service X-Article-Creation-Date: Sun Mar 30 03:02:16 1997 GMT X-Authenticated-Sender: yus000@unbc.edu Reply-To: yus000@unbc.edu Newsgroups: comp.lang.ada Date: 1997-03-29T00:00:00+00:00 List-Id: Hi, i have a urgent question. I am doing assignment on stacks. We have to declare the stack as "limited private type" As a result, in my main program, i need to initiate the stack. Do i use with Text_IO; use Text_IO; with ordered_stack; use ordered_stack; procedure main is begin declare w: stack; -- line 7 m: integer := 4; n: integer := 3; k: integer := 2; begin push(w, m); push(w, n); push(w, k); end; end main; *** i get the error" subtype mark required in this context" How do i arrange my main program??? I tried to change it to : type w is new ordered_stack, but i still get errors. Please help!!! thanks. ---------------------------------------------------------------- with ordered_stack; --use ordered_stack; with Text_IO; use Text_IO; procedure testorder is a,b,c,d : integer; begin declare use ordered_stack; a : integer := 4; b : integer := 3; c : integer := 2; d : integer := 1; -- a, b, c, d : integer; type w is new ordered_stack; --type p is new ordered_stack; --subtype w is p; -- stack; begin -- a := 4; -- b := 3; --c := 2; --d := 1; --begin push(w,a); push(w,b); push(w,c); push(w,d); put(" is going to print"); New_Line; print(w); end; end testorder; ---------------------------------------------------------- ------------------------------------------------------------------ with Gnat.IO; use Gnat.IO; package body ordered_stack is procedure push(s: in out stack; x: in integer) is k: cell_ptr; begin k := new cell'(value=>x, next=>null); s.list.next := k; s.list := k; s.count := s.count + 1; end push; --//////////////////////////////////////// function empty (s: stack) return Boolean is begin return s.list = null; end empty; --///////////////////////////////////////////// procedure pop(s: in out stack; x: out integer)is begin x:= s.list.value; s.list := s.list.next; end pop; --//////////////////////////////////////////////// function top(s: stack) return integer is begin return s.list.value; end top; --//////////////////////////////////////////////////// procedure print(s: out stack) is i: integer; m: integer; begin m := s.count; Put("The ordered stack is as follows"); New_Line; for i in 1 .. m loop put(integer(s.list.value)); end loop; New_Line; end print; end ordered_stack; --------------------------------------------------------------------- ******************************************************************* package ordered_stack is type stack is limited private; procedure push(s: in out stack; x: in integer); function empty (s: stack) return Boolean; procedure pop (s: in out stack; x: out integer); function top (s: stack) return integer; -- function top return integer; procedure print(s: out stack); private type cell; type cell_ptr is access cell; type cell is record value: integer; next: cell_ptr; end record; type stack is record --max: constant := 100; --type integer_vector is array(integer range<>) of integer; --s: interger_vector(1 .. max); --top: integer range 0 .. max := 0; count: integer:= 0; list: cell_ptr; end record; end; ********************************************************************* -------------------==== Posted via Deja News ====----------------------- http://www.dejanews.com/ Search, Read, Post to Usenet