• 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: Private, Protected methods in Obj C?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Private, Protected methods in Obj C?


  • Subject: Re: Private, Protected methods in Obj C?
  • From: Andy <email@hidden>
  • Date: Wed, 03 Apr 2002 21:28:52 -0500

Andy Lee wrote:
>
> At 12:14 AM +0200 4/4/02, Ondra Cada wrote:
> >On Thursday, April 4, 2002, at 12:04 , Jonathan Wight wrote:
> >>Static functions should be used inside a class only as a method of last
> >>resort. If you use them you sacrifice all of Objective C's dynamic
> >>loveliness. Dont do it. If you need (mostly) private methods put them
> >>inside their own hidden categories.
> >
> >I guess one of us two does not know what a "private method" is
> >(might easily be me -- I have never been an expert in those C++
> >thingies!). Anyway:
> >
> >- is it inheritable?
> >- is it overridable?
> >
> >I guess twice nope.
>
> You are right on both counts, at least the way Java defines
> "private." I don't remember about C++.
>

You're right about the super thing, and though to pick a nit, while you
can't override a private method in Java you can hide one:

class A {
private void m() {}
}

class B extends A {
private void m() {}
}

class C extends B {

private void m() { super.m(); }
}

This doesn't compile because m is private in b (so you can't override,
true). But you can hide, B and A will compile if you delete C.
Effectively m in B is a completely different method to m in A. You can
even declare m in A "final" and B will still compile.

Sometimes I miss this strong encapsulation in Objective-C.

--
AndyT (lordpixel - the cat who walks through walls)
A little bigger on the inside

I think we finally found the killer app for Flash: animated stick men
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.

References: 
 >Re: Private, Protected methods in Obj C? (From: Ondra Cada <email@hidden>)
 >Re: Private, Protected methods in Obj C? (From: Andy Lee <email@hidden>)

  • Prev by Date: POSIX Path to HFS?
  • Next by Date: Changing the menu bar
  • Previous by thread: Re: Private, Protected methods in Obj C?
  • Next by thread: Re: Private, Protected methods in Obj C?
  • Index(es):
    • Date
    • Thread