comp.lang.ada
 help / color / mirror / Atom feed
From: abacon@cps.udayton.edu (Adam C. Bacon)
Subject: Polymorphism/Inheritence
Date: 1997/02/26
Date: 1997-02-26T00:00:00+00:00	[thread overview]
Message-ID: <5f0pcc$5b9@news.cps.udayton.edu> (raw)


I am a Computer Science student at the University of Dayton using the
GNAT Compiler for Ada 95.  One of our recent problems was to write a
simple set of packages and a driver program to illustrate the principles
of inheritence and polymorphism.  In doing the assignment, I discovered
a difference (which I believe may be a bug) between version 2.06S of
the GNAT compiler (for DOS, using DJGPP) and versions 3.04 and higher.

In my parent package specification, I have the parent type in the
hierarchy declared as a tagged private type:
  type Vehicle is tagged private;

I also have a pointer declared as follows:
  type Vehicle_Pointer is access Vehicle'Class;

In a child package specification, I have a private type declared as follows:
  type Car is new Vehicle with private;

I have two local variables defined in the child package body as follows:
  Pointer  : Vehicle_Pointer;
  Temp_Car : Car;

The problem that I have arises when I make an assignment in a function
defined in the child package body.  The assignment occurs in a Create
procedure, which is as follows:
  Pointer.all := Temp_Car;

Prior to this assignment, I make the following:
  Pointer := new Car;

The error which I receive from the compiler is the following:
  Pointer.all := Temp_Car;
                 |
  dynamically tagged expression required

After discussing this problem with my professor and with other students,
we are unable to find out why this occurs, especially since it does not
occur in GNAT version 2.06S, only in versions 3.04 and higher.  If anyone
else has experienced this problem, I would be interested in discussing
any possible solutions you have found.

Thanks,
Adam Bacon




             reply	other threads:[~1997-02-26  0:00 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1997-02-26  0:00 Adam C. Bacon [this message]
1997-02-26  0:00 ` Polymorphism/Inheritence Jon S Anthony
1997-02-28  0:00   ` Polymorphism/Inheritence Stephen Leake
1997-03-01  0:00   ` Polymorphism/Inheritence Robert Dewar
1997-03-03  0:00   ` Polymorphism/Inheritence Jon S Anthony
1997-02-27  0:00 ` Polymorphism/Inheritence Robert Dewar
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox