advertisement

Article:
  The Objective-C Language
Subject:   + initialize and - init /not/ compared to constructors in C++
Date:   2001-05-07 10:45:12
From:   mikebeam
Response to: + initialize and - init /not/ compared to constructors in C++

I stand corrected about + alloc setting all instances variables to zero rather than - init.


Additionally, when i said init is like a constructor, I was thinking in the sense of Java. I could see the two things being equivalent for a class (say the class is a circle).


Java Constructor:
Circle aCircle = new Circle(10);


where the argument for this constructor is the radius of the circle. In Obj-C this might look like:


Circle *aCircle = [[Circle alloc] initWithRadius:10];


If I was being loose with OOP terminology, I apologize.


1 to 1 of 1
  1. + initialize and - init /not/ compared to constructors in C++
    2001-05-07 21:08:18  gskluzacek [View]

    • Michael Beam photo + initialize and - init /not/ compared to constructors in C++
      2001-05-08 12:27:34  Michael Beam | O'Reilly Author [View]

1 to 1 of 1