comp.lang.ada
 help / color / mirror / Atom feed
From: Stephen Leake <stephen_leake@acm.org>
To: comp.lang.ada@ada-france.org
Subject: Re: how can i allocate an objekt with initialization???
Date: 05 Dec 2004 17:51:25 -0500
Date: 2004-12-05T17:51:25-05:00	[thread overview]
Message-ID: <mailman.175.1102287126.10401.comp.lang.ada@ada-france.org> (raw)
In-Reply-To: <covegl$qvq$04$1@news.t-online.com>

Thomas Bruns <newsgroup@donbruno.de> writes:

> Hello
> 
> i have a problem, with initialzie objekt with ada...
> 
> i want to do a new, to allocate the objekt... 

Here's a version of your code that compiles (except it is missing a
package body):

with ADA.FINALIZATION; use ADA.FINALIZATION;
package class_test_package is

 type FATHER_CLASS is new CONTROLLED with
  record
   INT1 : INTEGER;
  end record;

 type FATHER_CLASS_PTR is access all FATHER_CLASS'Class;

 function GETINT1 return INTEGER is abstract;

end class_test_package;

with class_test_package; use class_test_package;
package class_test_package_ableitung is

type CHILD_CLASS is new FATHER_CLASS with private;

type CHILD_CLASS_PTR is access CHILD_CLASS'CLASS;

function Factory (Int1, Int2 : in Integer) return Child_Class_Ptr;

private

 procedure Initialize (OBJECT : in out Child_CLASS);

 procedure Finalize  (OBJECT : in out CHILD_CLASS);

 procedure ADJUST (OBJECT : in out CHILD_CLASS);

 type CHILD_CLASS is new FATHER_CLASS with
  record
   INT2 : INTEGER;
  end record;

end class_test_package_ableitung;

with Class_Test_Package;
with Class_Test_Package_Ableitung;
procedure Main is

TEST : Class_Test_Package.FATHER_CLASS_PTR;

begin
 TEST := Class_Test_Package.FATHER_CLASS_PTR
    (Class_Test_Package_Ableitung.Factory (INT1 => 1, Int2 => 2));

end Main;


Your problem was that Child_Class is a private type; you cannot create
an aggregate for it. The body of Factory can use an aggregate.

Hope this helps.

-- 
-- Stephe




  reply	other threads:[~2004-12-05 22:51 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-12-05 16:54 how can i allocate an objekt with initialization??? Thomas Bruns
2004-12-05 22:51 ` Stephen Leake [this message]
2004-12-06  8:52 ` Martin Krischik
2004-12-06 10:04   ` Ole-Hjalmar Kristensen
2004-12-06 11:49     ` Adrien Plisson
2004-12-06 13:34       ` Martin Krischik
2004-12-13  6:38         ` Dave Thompson
2004-12-13 11:11           ` Martin Krischik
2004-12-06 11:55     ` Martin Krischik
replies disabled

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