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=-0.3 required=5.0 tests=BAYES_00, REPLYTO_WITHOUT_TO_CC autolearn=no 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!news2.google.com!news.maxwell.syr.edu!newsfeed.icl.net!newsfeed.fjserv.net!feed.news.tiscali.de!newsfeed01.sul.t-online.de!newsmm00.sul.t-online.de!t-online.de!news.t-online.com!not-for-mail From: Martin Krischik Newsgroups: comp.lang.ada Subject: Re: newbie - OOP in Ada Set and Get Methods Date: Tue, 28 Dec 2004 14:39:17 +0100 Organization: None Message-ID: <1726951.jUzHJz4Fbz@linux1.krischik.com> References: <1104237673.373489.128290@z14g2000cwz.googlegroups.com> Reply-To: martin@krischik.com Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7Bit X-Trace: news.t-online.com 1104241575 02 29648 HhSsrDyJzzNl9P7 041228 13:46:15 X-Complaints-To: usenet-abuse@t-online.de X-ID: r2m5AyZOZenp9pOejn24mXaY9yc+EZqJGP6XxdfQndkwA99CBcK68i User-Agent: KNode/0.8.0 Xref: g2news1.google.com comp.lang.ada:7259 Date: 2004-12-28T14:39:17+01:00 List-Id: R wrote: > Hello. > > I'm new to Ada95. I was trying to create on 'object' in Ada with Set > and Get methods. > > But I failed... > > I'm not sure whether or not my thinking in Ada is proper - Ada verries > a lot from C++ and Java OOP... > > My codes are below > > thanks in advance > > best regards R > > main.db unit: > > with Text_IO; > use Text_IO; > with testclass; > procedure Main is > T: testclass.rec1; > begin > T.Set(5); > Put_Line(Integer'Image(T.Get)); > end Main; > > testclass.ads: > package testclass is > > type rec1 is tagged null record; --is abstract If you want an abstract class you should say so: type rec1 is abstract tagged null record: Of corse when testclass is abstract then you need a non abstract testclass_2 :-). So maybe you don't want an abstract class after all. > field: Integer; field should be part of record "rec1" otherwise it is "static" to use C++ talk! > function Set(s: Integer) return Integer; > function Get return Integer; function Set(s: Integer) return Integer is abstract; function Get return Integer is abstract; > > end testclass; > > and testclass.adb > package body testclass is > function Set(s: Integer) return Integer is > begin > field := s; > return field; > end Set; > > function Get return Integer is > begin > return field; > end Get; > end testclass; Where did you actualy fail? Suggested Reading: http://en.wikibooks.org/wiki/Programming:Ada:OO http://en.wikibooks.org/wiki/Programming:Ada:Types:record With Regards Martin -- mailto://krischik@users.sourceforge.net http://www.ada.krischik.com