id - Page 50
Hi all, isn’t this book great?
I was wondering if anyone could shed some more light on this extract from the book:
[quote]Take another look at the initializer’s declaration. Its return type is id, which is defined as “a pointer
to any object.” (This is a lot like void * in C and is pronounced “eye-dee.”) init methods are always
declared to return id.[/quote] - I get this
[quote]Why not make the return type Possession * – a pointer to a Possession? After all, that is the type
of object that is returned from this method. A problem will arise, however, if Possession is ever
subclassed.[/quote] - I get
[quote]The subclass would inherit all of the methods from Possession, including this initializer
and its return type. An instance of the subclass could then be sent this initializer message, but what
would be returned? Not a Possession, but an instance of the subclass.[/quote] - I am not clear why a Possession wouldn’t be returned if the class was subclassed, what changes in the subclass if a class is subclassed?