• 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: Ondra Cada <email@hidden>
  • Date: Wed, 29 Aug 2001 16:11:22 +0200

Chris,

>>>>>> Chris Gehlker (CG) wrote at Wed, 29 Aug 2001 06:44:02 -0700:
CG> >That's not true: *if* you implement a virutal class, there is no need to
CG> >bother with init/dealloc of it. Actually, you can forget that also for
CG> >classes which are *not* abstract at all, but just happen to have no
CG> >"constructable/destructable" properties.
CG>
CG> Can you? What if you derive from it? How does its parent constr/destr get
CG> called when you construct/destruct a child class.

They would be inherited, of course. Where's the problem?

@interface OriginalClass ... @end
@implementation OriginalClass
-init { ....anything.... } /**/
// for dealloc the very same would apply
@end

@interface YourClass:OriginalClass ... @end
@implementation YourClass
// whatever there, it's no init nor dealloc
@end

@interface SomebodysClass:YourClass ... @end
@implementation SomebodysClass
-init {
[super init]; // the /**/ implementation called here, of course
...
}
@end

Should there be any number of intermediate classes, it would work as well:
say, you have an inheritance chain A:B:C:D:E:F:G:H:NSObject, none of B-H
implements dealloc. Then [super dealloc] in A would call the NSObject's
implementation.

We are in object-oriented environment, and so we have inheritance. It's that
simple.

Do forget the C++ constructor/desctructor nonsense; init/dealloc are quite
normal methods, in no way special (but by some conventions of using them).
Especially, they are inherited just like any other method is.
---
Ondra Cada
OCSoftware: email@hidden http://www.ocs.cz
private email@hidden http://www.ocs.cz/oc


  • Follow-Ups:
    • Re: Abstract classes and methods
      • From: Chris Gehlker <email@hidden>
References: 
 >Re: Abstract classes and methods (From: Chris Gehlker <email@hidden>)

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