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!z14g2000cwz.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 09:30:55 -0800 Organization: http://groups.google.com Message-ID: <1104255055.672275.111440@z14g2000cwz.googlegroups.com> References: <1104237673.373489.128290@z14g2000cwz.googlegroups.com> <1104251213.061878.187430@f14g2000cwb.googlegroups.com> NNTP-Posting-Host: 83.238.46.94 Mime-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" X-Trace: posting.google.com 1104255062 11447 127.0.0.1 (28 Dec 2004 17:31:02 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Tue, 28 Dec 2004 17:31:02 +0000 (UTC) In-Reply-To: User-Agent: G2/0.2 Complaints-To: groups-abuse@google.com Injection-Info: z14g2000cwz.googlegroups.com; posting-host=83.238.46.94; posting-account=vW-V7A0AAADVHjc0FRFWzwhUHLUBcq4I Xref: g2news1.google.com comp.lang.ada:7267 Date: 2004-12-28T09:30:55-08:00 List-Id: Jeff C r e e.m wrote: > It is not possible for anyone to answer this question since we don't know > what you > are trying to accomplish. I'm only trying to write a constructor. Package testclass. testclass.Create is meant to be my constructor given main unit: with Text_IO; use Text_IO; with testclass; -- include testclass package procedure Main is object : testclass.rec1_Type := testclass.Create(10); begin Put_Line(Integer'Image(testclass.Get(object))); end Main; testclass specyfication: package testclass is type rec1 is tagged private; type rec1_Type is access rec1; function Create(s: Integer) return rec1_Type; function Set(this: rec1_Type; s: Integer) return Integer; function Get(this: rec1_Type) return Integer; private type rec1 is tagged record field: Integer; end record; end testclass; testclass body: package body testclass is function Create(s: Integer) return rec1_Type is begin return testclass.rec1_Type(field=>s); end Create; function Set(this: rec1_Type; s: Integer) return Integer is begin this.field := s; return this.field; end Set; function Get(this: rec1_Type) return Integer is begin return this.field; end Get; end testclass; during compilation gnatmake points an error to: return testclass.rec1_Type(field=>s); $ gcc -c testclass.adb testclass.adb:5:33: invalid prefix in call gnatmake: "testclass.adb" compilation error (the 5th line of testclass is return statement) and I don't know how to write this constructor to return the access type rec1_Type to rec1 hope it helps to help me ;-) thanks in advance best regards R