Re: OOP Clarification
Re: OOP Clarification
- Subject: Re: OOP Clarification
- From: Rick <email@hidden>
- Date: Fri, 4 Jan 2002 16:41:30 -0600
On Friday, January 4, 2002, at 10:25 AM, Marco Scheurer wrote:
On Friday, January 4, 2002, at 04:40 pm, Smith, Bradley wrote:
When you say you can't overload static methods I'm not sure what you
mean.
I meant overriding. Can you redefine a static method in a subclass and
invoke the base class implementation?
C++ Static methods cannot be redefined in that sense as they don't use
the virtual keyword and polymorphism thus doesn't apply. It is
perfectly legal though to do the following:
class A
{
static void foo (void);
};
void A::foo (void) { }
class B : public A
{
static void foo (void);
};
void B::foo (void)
{
A::foo();
}
Above, you have the same static method (name and args) in both the
parent and derived class. However, the one in B doesn't override the
one in A. Static methods don't have a "this" pointer, so there's
nothing to apply polymorphism to.
Same applies to Obj-C...you don't have "self" and "super" inside those
class methods, so you can't override or access parent class methods.
But, just as shown above, you can have the same class methods in
multiple Obj-C classes.
--------------------------------------------------
Ricky A. Sharp Instant Interactive(tm)
Founder & President www.instantinteractive.com
mailto:email@hidden
--------------------------------------------------