From: "David C. Hoos, Sr." <david.c.hoos.sr@ada95.com>
Subject: Re: A bunch of questions that come after "Hello world"
Date: Thu, 14 Nov 2002 05:21:36 -0600
Date: 2002-11-14T05:21:36-06:00 [thread overview]
Message-ID: <mailman.1037272923.17851.comp.lang.ada@ada.eu.org> (raw)
In-Reply-To: 5ad0dd8a.0211140218.6d48be15@posting.google.com
----- Original Message -----
From: "Wojtek Narczynski" <wojtek@power.com.pl>
Newsgroups: comp.lang.ada
To: <comp.lang.ada@ada.eu.org>
Sent: November 14, 2002 4:18 AM
Subject: Re: A bunch of questions that come after "Hello world"
> Robert A Duff <bobduff@shell01.TheWorld.com> wrote in message
news:<wcck7jhfar3.fsf@shell01.TheWorld.com>...
> > wojtek@power.com.pl (Wojtek Narczynski) writes:
> >
> > > 2. Could somebody confirm that I cannot define a procedure / function
> > > as a member of a "record", but I sure can as a member of "protected"?
> >
I Guess the best way to answer your question is to
show you the Ada way to do what you want, viz.:
-- File: doors.ads
package Doors is
type Door is private;
procedure Open (This : in out Door);
procedure Close (This : in out Door);
function Is_Open (This : Door) return Boolean;
private
type Door is record
Open : Boolean := False;
end record;
end Doors;
-- File: doors.adb
package body Doors is
-----------
-- Close --
-----------
procedure Close (This : in out Door) is
begin
This.Open := False;
end Close;
-------------
-- Is_Open --
-------------
function Is_Open (This : Door) return Boolean is
begin
return This.Open;
end Is_Open;
----------
-- Open --
----------
procedure Open (This : in out Door) is
begin
This.Open := True;
end Open;
end Doors;
-- File: test_doors.adb
with Ada.Text_IO;
with Doors;
procedure Test_Doors
is
Front_Door : Doors.Door;
begin
Ada.Text_IO.Put_Line
("Initial state of a Doors.Door object is open? " &
Boolean'Image (Doors.Is_Open (Front_Door)));
Ada.Text_IO.Put_Line ("Opening Front_Door..");
Doors.Open (Front_Door);
Ada.Text_IO.Put_Line
("Front_Door is open? " &
Boolean'Image (Doors.Is_Open (Front_Door)));
Ada.Text_IO.Put_Line ("Closing Front_Door..");
Doors.Close (Front_Door);
Ada.Text_IO.Put_Line
("Front_Door is open? " &
Boolean'Image (Doors.Is_Open (Front_Door)));
end Test_Doors;
<snip>
> I have two more questions:
> 1. Is there something like super in Java?
No.
> 2. Can I overload () operator? I guess no.
There is no "()" operator in Ada. In Ada, when a
sub program requires no parameters, you just don't
write thge "()."
<snip>
next prev parent reply other threads:[~2002-11-14 11:21 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2002-11-13 20:44 A bunch of questions that come after "Hello world" Wojtek Narczynski
2002-11-13 20:57 ` Robert A Duff
2002-11-14 10:18 ` Wojtek Narczynski
2002-11-14 11:21 ` David C. Hoos, Sr. [this message]
2002-11-14 19:51 ` tmoran
2002-11-14 21:51 ` Robert A Duff
2002-11-15 17:50 ` Wojtek Narczynski
2002-11-15 23:07 ` Robert A Duff
2002-11-18 10:24 ` Wojtek Narczynski
2002-11-18 11:54 ` Dmitry A. Kazakov
2002-11-18 16:24 ` Wojtek Narczynski
2002-11-18 21:19 ` Robert A Duff
2002-11-19 8:48 ` Dmitry A. Kazakov
2002-11-13 22:06 ` Martin Dowie
2002-11-14 17:48 ` Pascal Obry
2002-11-14 18:53 ` David C. Hoos
2002-11-14 22:36 ` Martin Dowie
2002-11-15 1:25 ` Jeffrey Carter
2002-11-13 22:31 ` Stephen Leake
-- strict thread matches above, loose matches on Subject: below --
2002-11-18 10:32 Grein, Christoph
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox