home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.lang.ada
- Path: sparky!uunet!cis.ohio-state.edu!zaphod.mps.ohio-state.edu!rpi!batcomputer!munnari.oz.au!cs.mu.OZ.AU!munta.cs.mu.OZ.AU!fjh
- From: fjh@munta.cs.mu.OZ.AU (Fergus James HENDERSON)
- Subject: Re: Type Extensions VS Classes (was Re: Object Oriented Ada...)
- Message-ID: <9222602.8953@mulga.cs.mu.OZ.AU>
- Sender: news@cs.mu.OZ.AU
- Organization: Computer Science, University of Melbourne, Australia
- References: <1992Aug4.172639.17168@ichips.intel.com> <BEVAN.92Aug4213057@otter.cs.man.ac.uk> <9222000.23050@mulga.cs.mu.OZ.AU> <59503@mimsy.umd.edu>
- Date: Wed, 12 Aug 1992 16:53:02 GMT
- Lines: 40
-
- alex@cs.umd.edu (Alex Blakemore) writes:
-
- >In article <9222000.23050@mulga.cs.mu.OZ.AU> fjh@munta.cs.mu.OZ.AU (Fergus James HENDERSON) writes:
- >> Does Ada-9X have any concept similar to C++'s abstract base classes?
- >
- >Yes.
- >
- >An abstract type is one that has one or more abstract operations.
- >An abstract operation (subprogram) has no body. They are used to define
- >the profile of an operation that (non abstract) types derived
- >from the abstract parent must provide.
- >
- >It is a compile time error to declare an object of an
- >abstract type. That is an improvement over C++.
-
- It *is* an error to declare an object of an abstract type in C++.
- For example:
- $ cat > abstract.c
- class Shape {
- public:
- virtual void draw() = 0;
- };
- int main(void) {
- Shape s;
- return 0;
- }
- $ CC abstract.c
- "abstract.c", line 6: error: declaration of object of abstract class Shape
-
- >If you want the C++ ability to declare objects of the
- >abstract type (which means that the type is not really abstract),
- >just supply a null body for the relevant operations.
-
- C++ does not have this ability.
-
- --
- Fergus Henderson fjh@munta.cs.mu.OZ.AU
- This .signature VIRUS is a self-referential statement that is true - but
- you will only be able to consistently believe it if you copy it to your own
- .signature file!
-