comp.lang.ada
 help / color / mirror / Atom feed
From: Martin Krischik <martin@krischik.com>
Subject: Re: how can i allocate an objekt with initialization???
Date: Mon, 06 Dec 2004 09:52:04 +0100
Date: 2004-12-06T09:52:04+01:00	[thread overview]
Message-ID: <3459883.9H2ke8dEzz@linux1.krischik.com> (raw)
In-Reply-To: covegl$qvq$04$1@news.t-online.com

Thomas Bruns wrote:

> TEST : FATHER_CLASS_PTR;
> 
> begin
>  TEST:= new CHILD_CLASS'( INT=>1); -- i will initialze the objekt here,but

Since you are initializing an element form the parent class you need to
initialize the child as well:

TEST:= new CHILD_CLASS'(
                         INT1 =>1
                         INT2 =>1);

only the other way round you can shortcut:

TEST:= new CHILD_CLASS'(
                         FATHER_CLASS
                     WITH
                         INT2 =>1); 

And the standart question for beginners: Are you shure you need a pointer?
Unlike C/C++/Java Ada allows for:

TEST : FATHER_CLASS'Class  :=ï¿œCHILD_CLASS'(
                         INT1 =>1
                         INT2 =>1);

You can use inheritance in Ada without using pointers! FATHER_CLASS'Class
can be used just like a String - you can pass it around as parameter,
return it from a function, store it in a record. There are collection
libraries where you can store them.

With Regards

Martin
-- 
mailto://krischik@users.sourceforge.net
http://www.ada.krischik.com



  parent reply	other threads:[~2004-12-06  8:52 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
2004-12-06  8:52 ` Martin Krischik [this message]
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