• 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: Subject: Inherited constructors
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Subject: Inherited constructors


  • Subject: Re: Subject: Inherited constructors
  • From: Simon Stapleton <email@hidden>
  • Date: Thu, 30 Aug 2001 09:38:41 +0100 (BST)

> From: email@hidden
> Date: Wed, 29 Aug 2001 20:43:28 +0200
> Cc: email@hidden
> To: email@hidden
> Subject: Inherited constructors

<snip>

> No, in general I find Obj-C extremely elegant and powerful, but I
> think it would be better if constructors were not inherited.
>
> Drew McCormack

The -(id)init group of methods aren't constructors. They're just
methods like any other. You could, should you so desire, design a
new base class and have the following methods:

+ (id) grabMemory;
- (id) construct;

...and then construct your classes with
[[myClass grabMemory] construct];

The point is, that init is just a method, and there is no way in hell
that the compiler could recognise it to stop it being inherited
without breaking a load of other stuff in the process. On top of
that, who _wants_ 'special' methods which aren't like all the others
anyway?

IMO, one of the biggest pains of C++ programming is the fact that
constructors and destructors aren't normal methods, and that half the
programmers I work with don't understand _when_ constructors get
called, or why[1].

Simon

[1] The fact that a good number of the 'C++ experts' mentioned earn
more than me is a mere annoyance.

--
If the answer isn't obvious, the question is a distraction. Go find
an
easier question.


  • Follow-Ups:
    • Re: Subject: Inherited constructors
      • From: Ondra Cada <email@hidden>
  • Prev by Date: NSArchiver? try again
  • Next by Date: Re: speed daemons
  • Previous by thread: Re: NSArchiver? try again
  • Next by thread: Re: Subject: Inherited constructors
  • Index(es):
    • Date
    • Thread