From: Martin Krischik <martin@krischik.com>
Subject: Re: newbie - OOP in Ada Set and Get Methods
Date: Tue, 28 Dec 2004 14:39:17 +0100
Date: 2004-12-28T14:39:17+01:00 [thread overview]
Message-ID: <1726951.jUzHJz4Fbz@linux1.krischik.com> (raw)
In-Reply-To: 1104237673.373489.128290@z14g2000cwz.googlegroups.com
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
prev parent reply other threads:[~2004-12-28 13:39 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
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 [this message]
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox