• 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: OOP Clarification
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

RE: OOP Clarification


  • Subject: RE: OOP Clarification
  • From: "Smith, Bradley" <email@hidden>
  • Date: Fri, 4 Jan 2002 15:40:22 -0000

Well, it does have a 'this' in the sense that it can access other static
variables and methods.
When you say you can't overload static methods I'm not sure what you mean.
This is fine for example:

class foo
{
static int m_age;
public:
static void initialize(char* name);
// overload to include age as well
static void initialize(char* name, int age);
};

int foo::m_age;

void foo::initialize(char* name)
{
}

void foo::initialize(char* name, int age)
{
// call other static method
initialize(name);
// access static variable
m_age = age;
}

void main(void)
{
foo myFoo, myFoo2;
myFoo.initialize("Brad");
myFoo2.initialize("Mia", 0);
}

I'm not trying to get into an argument here, it's just that I'm new to Obj-C
and in my head I had class members in Obj-C as analagous to static members
in C++. Would someone care to point out the differences, and I mean the
differences in how one can be used in a way that the other cannot.

Many thanks
Brad

> -----Original Message-----
> From: Marco Scheurer [mailto:email@hidden]
> Sent: 04 January 2002 15:21
> To: Smith, Bradley
> Cc: email@hidden
> Subject: Re: OOP Clarification
>
>
> From: "Smith, Bradley" <email@hidden>
>
> > C++ has class methods too (static methods). They too are
> often used as
> > class
> > factory methos, but not always.
> >
> > One of the few similarities between C++ and Obj-C from what
> I've seen so
> > far.
>
> And not an impressive one, of course: static methods are no
> more class
> methods than static variables are class variables in
> Objective C. A C++
> static method cannot be overloaded, has no "this".
>
> Marco Scheurer
> Sen:te, Lausanne, Switzerland http://www.sente.ch


  • Follow-Ups:
    • RE: OOP Clarification
      • From: Chris Hanson <email@hidden>
    • Re: OOP Clarification
      • From: "Erik M. Buck" <email@hidden>
    • Re: OOP Clarification
      • From: Marco Scheurer <email@hidden>
  • Prev by Date: Can these be done in Cocoa?
  • Next by Date: Re: Can these be done in Cocoa?
  • Previous by thread: Re: OOP Clarification
  • Next by thread: Re: OOP Clarification
  • Index(es):
    • Date
    • Thread