• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Abstract classes and methods
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Abstract classes and methods


  • Subject: Re: Abstract classes and methods
  • From: Karl Goiser <email@hidden>
  • Date: Wed, 29 Aug 2001 23:53:02 +1000

If you never instantiate a class, isn't it, necessarily, abstract?

The question, then, should be (as you were saying) "How do I stop anybody from instantiating a particular class?"

And the answer to this would be to override 'alloc' or something like that and put an error message in it...

Karl

P.S. If you say "Please don't instantiate 3DObject" in your header file and somebody goes ahead anyway, what hope do you have on ensuring quality?


At 10:55 PM +1000 30/8/01, stuartbryson wrote:
I find it quite amusing that this is the exact example that I need it for (except that I am working in 3D rather than 2D). I have a 3DObject and then Sphere and Cube both inherit from 3DObject. I do not want anyone (me) to be able to instantiate 3d object. It is easy to say "Please don't instantiate 3DObject" to those who might use my code, but if I could force it like in C++ this would ensure the quality of the program etc etc.

Stuart

On Wednesday, August 29, 2001, at 10:11 PM, Smith, Bradley wrote:

Okay, classic OO example. I have an abstract class called Shape.
Shape is meaningless on its own but if you subclass it e.g. Square, Circle
etc. then those classes can be used. What you don't want to do is let anyone
using your classes instantiate an instance of class Shape directly.

Brad


If you describe a situation which would be impossible or at
least quite
inconvenient to solve without abstract classes -- I am not
aware of any such
-- I'll do my best to answer.
---
Ondra Cada
OCSoftware: email@hidden http://www.ocs.cz
private email@hidden http://www.ocs.cz/oc
_______________________________________________
cocoa-dev mailing list
email@hidden
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
_______________________________________________
cocoa-dev mailing list
email@hidden
http://www.lists.apple.com/mailman/listinfo/cocoa-dev


--
----
Klaatu barada nikto


  • Follow-Ups:
    • Re: Abstract classes and methods
      • From: Ondra Cada <email@hidden>
References: 
 >Re: Abstract classes and methods (From: stuartbryson <email@hidden>)

  • Prev by Date: Re: Abstract classes and methods
  • Next by Date: Re: Help with crash log
  • Previous by thread: Re: Abstract classes and methods
  • Next by thread: Re: Abstract classes and methods
  • Index(es):
    • Date
    • Thread