From: "Peter C. Chapin" <pchapin@sover.net>
Subject: Re: types and subtypes
Date: 17 Mar 2006 01:24:55 GMT
Date: 2006-03-17T01:24:55+00:00 [thread overview]
Message-ID: <Xns9788CFB2AE5F5pchapinsovernet@198.186.192.137> (raw)
In-Reply-To: 1142273325.634632.41020@j52g2000cwj.googlegroups.com
ada_student@yahoo.com wrote in news:1142273325.634632.41020
@j52g2000cwj.googlegroups.com:
> Why doesnt Ada subtyping also denote derivation as in the
> sense C++ base classes and derived classes do?
>
> Why was Ada's subtyping defined to exclude derivation?
Consider this...
Suppose you had a C++ base class Vehicle from which you derived a class
Car.
class Vehicle { };
class Car : public Vehicle { };
In OO terms, Car is a "subtype" of Vehicle. But this is consistent with
Ada's Positive being a subtype of Integer. The set of Car values is a
subset of the set of Vehicle values just as the set of Positive values
is a subset of the set of Integer values. To say a Vehicle is a Car is
to restrict it... no longer are you talking about just any Vehicle. It
is the same with Ada subtypes as far as I can see.
Of course it is likely that class Car has more members than class
Vehicle and thus has an extended implementation. However it defines a
more restricted class of objects.
Peter
prev parent reply other threads:[~2006-03-17 1:24 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-03-13 12:07 types and subtypes ada_student
2006-03-13 13:20 ` Jean-Pierre Rosen
2006-03-13 18:08 ` ada_student
2006-03-13 18:17 ` Ed Falis
2006-03-13 19:14 ` Larry Kilgallen
2006-03-13 19:42 ` Martin Krischik
2006-03-13 20:22 ` Wilhelm Spickermann
2006-03-14 8:47 ` Dmitry A. Kazakov
2006-03-14 14:39 ` Jean-Pierre Rosen
2006-03-17 1:24 ` Peter C. Chapin [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