TEAM-ADA Archives

Team Ada: Ada Programming Language Advocacy

TEAM-ADA@LISTSERV.ACM.ORG

Options: Use Forum View

Use Proportional Font
Show HTML Part by Default
Show All Mail Headers

Message: [<< First] [< Prev] [Next >] [Last >>]
Topic: [<< First] [< Prev] [Next >] [Last >>]
Author: [<< First] [< Prev] [Next >] [Last >>]

Print Reply
Subject:
From:
Rick Duley <[log in to unmask]>
Reply To:
Rick Duley <[log in to unmask]>
Date:
Mon, 23 Sep 2002 09:46:13 +0800
Content-Type:
text/plain
Parts/Attachments:
text/plain (63 lines)
Hi Teamers

I have been working on a class assignment in object-oriented programming
and have encountered a couple of curiosities.  The last time I did
user-defined OO I was using Borland Pascal Seven and Ada seems to
provide a less intuitive environment.  I think I am the last surviving
Ada programmer in the Perth education system and, with a dearth of texts
which deal with Ada OO, I am having real problems.

1. When I create a derived class, the methods of that class have no
direct assess to the attributes of the base class.  Therefore, to be
able to initialise an instance of the derived class I have to provide
the functionality in the base class to access those attributes, which
has the effect of making them public.  I am certain that students will
ask why we go to the trouble of making the tagged record private if we
are then to go to the trouble of making the data public.  Can someone
provide me with an explanation?

2.  Given the declaration:

      type Active_Area_Type is tagged limited private;

      type Active_Area_Access_Type is
      access all Active_Area_Type'Class;

if I then create an instance of the object by:

        Area : Active_Area_Access := new Active_Area_Type;


and at the end of the program run I want to deallocate the object using:

         procedure Free_Active_Area is
         new Ada.Unchecked_Deallocation
            (Object => Active_Area_Type,
             Name   => Active_Area_Access_Type);

I get an error message from the compiler (Gnat 3.13p) saying:

      'designated type of actual does not match that of formal "Name"'.

How can I deallocate objects?  I don't like having to leave the dirty
work up to the garbage collector.

Hoping someone will take the time to help here.
Thanks

---------------------------------------------------------

Rick Duley
School of Computing and Information Science
Edith Cowan University
2 Bradford St, Mt Lawley
Perth, Western Australia
tel: +61 8 9370 6619
fax: +61 8 9370 6100
mob: +61 040 910 6049                            /-_|\
                                                /     \
                                          perth *_.-._/
Experience is the worst of teachers                  v
          It gives you the exam
                        before it gives you the lecture

ATOM RSS1 RSS2