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 autolearn=ham autolearn_force=no version=3.4.4 X-Google-Thread: 103376,ccb21d128bf5f2ae X-Google-Attributes: gid103376,public X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!postnews.google.com!f14g2000cwb.googlegroups.com!not-for-mail From: "R" Newsgroups: comp.lang.ada Subject: Re: newbie - OOP in Ada Set and Get Methods Date: 28 Dec 2004 08:26:53 -0800 Organization: http://groups.google.com Message-ID: <1104251213.061878.187430@f14g2000cwb.googlegroups.com> References: <1104237673.373489.128290@z14g2000cwz.googlegroups.com> NNTP-Posting-Host: 213.199.248.59 Mime-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" X-Trace: posting.google.com 1104251217 5024 127.0.0.1 (28 Dec 2004 16:26:57 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Tue, 28 Dec 2004 16:26:57 +0000 (UTC) In-Reply-To: User-Agent: G2/0.2 Complaints-To: groups-abuse@google.com Injection-Info: f14g2000cwb.googlegroups.com; posting-host=213.199.248.59; posting-account=vW-V7A0AAADVHjc0FRFWzwhUHLUBcq4I Xref: g2news1.google.com comp.lang.ada:7261 Date: 2004-12-28T08:26:53-08:00 List-Id: 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