home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #18 / NN_1992_18.iso / spool / comp / lang / ada / 2352 < prev    next >
Encoding:
Text File  |  1992-08-12  |  1.9 KB  |  52 lines

  1. Newsgroups: comp.lang.ada
  2. 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
  3. From: fjh@munta.cs.mu.OZ.AU (Fergus James HENDERSON)
  4. Subject: Re: Type Extensions VS Classes (was Re: Object Oriented Ada...)
  5. Message-ID: <9222602.8953@mulga.cs.mu.OZ.AU>
  6. Sender: news@cs.mu.OZ.AU
  7. Organization: Computer Science, University of Melbourne, Australia
  8. 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>
  9. Date: Wed, 12 Aug 1992 16:53:02 GMT
  10. Lines: 40
  11.  
  12. alex@cs.umd.edu (Alex Blakemore) writes:
  13.  
  14. >In article <9222000.23050@mulga.cs.mu.OZ.AU> fjh@munta.cs.mu.OZ.AU (Fergus James HENDERSON) writes:
  15. >> Does Ada-9X have any concept similar to C++'s abstract base classes?
  16. >
  17. >Yes.
  18. >
  19. >An abstract type is one that has one or more abstract operations.
  20. >An abstract operation (subprogram) has no body. They are used to define
  21. >the profile of an operation that (non abstract) types derived
  22. >from the abstract parent must provide.
  23. >
  24. >It is a compile time error to declare an object of an
  25. >abstract type.  That is an improvement over C++.
  26.  
  27. It *is* an error to declare an object of an abstract type in C++.
  28. For example:
  29.     $ cat > abstract.c
  30.     class Shape {
  31.     public:
  32.         virtual void draw() = 0;
  33.     };
  34.     int main(void) {
  35.         Shape s;
  36.         return 0;
  37.     }
  38.     $ CC abstract.c
  39.     "abstract.c", line 6: error:  declaration of object of abstract class Shape
  40.  
  41. >If you want the C++ ability to declare objects of the
  42. >abstract type (which means that the type is not really abstract),
  43. >just supply a null body for the relevant operations.
  44.  
  45. C++ does not have this ability.
  46.  
  47. -- 
  48. Fergus Henderson             fjh@munta.cs.mu.OZ.AU      
  49. This .signature VIRUS is a self-referential statement that is true - but 
  50. you will only be able to consistently believe it if you copy it to your own
  51. .signature file!
  52.