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.9 required=5.0 tests=BAYES_00,FREEMAIL_FROM, T_FILL_THIS_FORM_SHORT autolearn=ham autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,362619d79933f738,start X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2003-12-08 11:49:19 PST Path: archiver1.google.com!postnews1.google.com!not-for-mail From: shoko2004@hotmail.com (shoko) Newsgroups: comp.lang.ada Subject: oo problem help please Date: 8 Dec 2003 11:49:19 -0800 Organization: http://groups.google.com Message-ID: <4948f537.0312081149.70179416@posting.google.com> NNTP-Posting-Host: 217.132.235.139 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit X-Trace: posting.google.com 1070912959 1360 127.0.0.1 (8 Dec 2003 19:49:19 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Mon, 8 Dec 2003 19:49:19 +0000 (UTC) Xref: archiver1.google.com comp.lang.ada:3242 Date: 2003-12-08T11:49:19-08:00 List-Id: what is wrong with the following code: ----car.ads---- package car is --car class -- type car is tagged private; type car_ptr is access all car'class; --car methods -- procedure set_name(name:String;this:in out car); function get_name(this:car) return string; private type car is tagged record name:String(1..256); end record; end car; ---car.adb--- package body car is procedure set_name(name:String;This:in out car)is begin this.name:=name; end set_name; function get_name(this:car) return string is begin return this.name; end get_name; end car; ----transport.ads----- with car; package transport is type transport_rec is new car.car with private; type transport_Ptr is access all transport_rec'Class; function init_transport(maximum_speed:positive) return transport_Ptr; private type transport_rec is new car.car with null record; end transport; -----transport.adb---- package body transport is function init_transport(maximum_speed:positive)return transport_Ptr is This: transport_Ptr; begin This:= new transport_Rec; return this; end init_transport; end transport; ----------bus.ads--- with transport; package bus is type bus is new transport.transport_rec with private ; type bus_Ptr is access all bus'Class; function initbus(name:string) return bus_Ptr; private type bus is new transport.transport_rec with null record; end bus; ---------bus.adb-------- package body bus is function initbus(name:String) return bus_Ptr is This: bus_ptr; begin This := new bus; set_name(name,this.all); <-- CONSTRAINT ERROR return this; end initbus; end bus; ------------------------------ and finally --------main.adb-------------- with car;use car; with bus;use bus; procedure main is cars:array(1..2) of car_ptr; new_bus:bus_ptr; begin cars(1) := car_ptr(initbus("mercedes")); end main; the problem is that i get constraint error when the code is executed why???