comp.lang.ada
 help / color / mirror / Atom feed
From: "R" <ruthless@poczta.onet.pl>
Subject: Re: newbie - OOP in Ada Set and Get Methods
Date: 28 Dec 2004 08:26:53 -0800
Date: 2004-12-28T08:26:53-08:00	[thread overview]
Message-ID: <1104251213.061878.187430@f14g2000cwb.googlegroups.com> (raw)
In-Reply-To: <WjdAd.650272$D%.214433@attbi_s51>

Jeff C r e e.m wrote:
> A few tips to think about
>
> 1) Packages are closer to namespaces than classes.
>     Your "field" variable is essentially just a stand alone 'global'
value
> that is in no way tied to your class
>
> 2) Tagged records are closer to "classes"

so if my class has 7 varaibles(3 of them are dynamically allocated
arrays) they should be all included inside tagged record?

That means that when im creating an object I have to pass as parameters
all
the variables?

> 3) There is no "this" in Ada so if you want an object to be visible
within a
> subprogram it needs to be a parameter.

thanks, I didn't know that

And one more thing about the tutorial which You said should be
shutdown.

It's written there that there is no such thing as contructor.
You'll have to define this function yourself.

so if I want create an object you should write sth like this:
object : testclass.rec1_Type := testclass.Create(10);

how should Create body look like?

rec1_Type is access to rec1 defined as tagged record with one variable
'field'.

when I wrote(package testclass):

function Create(s: Integer) return rec1_Type is
begin
return testclass.rec1_Type(field=>s);
end Create;

gnatmake gave me an error:

$ gnatmake main.adb
gcc -c testclass.adb
testclass.adb:5:33: invalid prefix in call
gnatmake: "testclass.adb" compilation error

where 5th line points to the return statement:
return testclass.rec1_Type(field=>s);
what am I doing wrong?

sorry... I'm just a Ada newbie

best regards R




  reply	other threads:[~2004-12-28 16:26 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-12-28 12:41 newbie - OOP in Ada Set and Get Methods R
2004-12-28 13:36 ` Jeff C r e e.m
2004-12-28 16:26   ` R [this message]
2004-12-28 17:01     ` Jeff C r e e.m
2004-12-28 17:30       ` R
2004-12-28 17:20     ` Martin Dowie
2004-12-28 17:36       ` R
2004-12-28 19:47         ` Mark Lorenzen
2004-12-28 19:48         ` Adrien Plisson
2004-12-28 19:58         ` Georg Bauhaus
2004-12-28 21:17         ` Martin Dowie
2004-12-29 10:06           ` R
2004-12-29 12:33             ` Martin Dowie
2004-12-29 17:35             ` Georg Bauhaus
2004-12-29 19:12             ` Martin Krischik
2004-12-30 12:14               ` Georg Bauhaus
2004-12-29 19:11         ` Martin Krischik
2004-12-28 13:39 ` 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