• 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: why Obj-C
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: why Obj-C


  • Subject: Re: why Obj-C
  • From: Dan Crevier <email@hidden>
  • Date: Thu, 04 Apr 2002 21:02:16 -0800

On 4/4/2002 8:46 PM, "Andy Lee" <email@hidden> wrote:

> * "self" is really "self", by which I mean the method that gets
> invoked for an object depends on the object's actual class at
> runtime, unlike C++ where the method invoked depends on the
> variable's declared type.

Maybe I'm just missing what you are saying here, but this is the basic
meaning of polymorphism, and is the way C++ works too. For example:

class A
{
public:
virtual void foo();
void bar() { this->foo(); }
};

class B
{
public:
virtual void foo();
};

void f()
{
B *b = new b;
A *bAsA = b;

bAsA->foo(); // calls B::foo()
bAsA->bar(); // calls B::foo()
}

Dan
_______________________________________________
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.

  • Follow-Ups:
    • Re: why Obj-C
      • From: Andy Lee <email@hidden>
References: 
 >Re: why Obj-C (From: Andy Lee <email@hidden>)

  • Prev by Date: Re: Double click time
  • Next by Date: Re: unichar question[SOLVED]
  • Previous by thread: Re: why Obj-C
  • Next by thread: Re: why Obj-C
  • Index(es):
    • Date
    • Thread