comp.lang.ada
 help / color / mirror / Atom feed
* Polymorphism/Inheritence
@ 1997-02-26  0:00 Adam C. Bacon
  1997-02-26  0:00 ` Polymorphism/Inheritence Jon S Anthony
  1997-02-27  0:00 ` Polymorphism/Inheritence Robert Dewar
  0 siblings, 2 replies; 6+ messages in thread
From: Adam C. Bacon @ 1997-02-26  0:00 UTC (permalink / 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




^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~1997-03-03  0:00 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1997-02-26  0:00 Polymorphism/Inheritence Adam C. Bacon
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

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