On May 19, 2008, at 6:18 PM, Brad Gibbs wrote:

It compiled and ran as expected, too. But, when I tried to eliminate allocation and initialization for newNumber in the first 'for loop', the app threw an exception. I don't see an explanation in the book re why numberToPrint can be, but doesn't need to be allocated or initialized. Is it because numberToPrint is simply pointing to newNumber objects in the array that have already been allocated and initialized? Could someone please explain this?


numberToPrint is a pointer to a memory address that may be an object; it is not an object itself. Creating a new object, and then replacing its only pointer with a pointer to a new object, is just wasting memory.

Nick Zitzmann
<http://www.chronosnet.com/>

_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]

Reply via email to