Re: why Obj-C
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.