Alex Rivera | Logout

Why are object variables declared with a star

Asked 2010-12-15T19:30:31.833
10

This may seem like trivial question.

But why is that we have to use the asterisk symbol when declaring object variables

Like, we do

Car * mazda = [[Car alloc] init];

What's the importance of the asterisk, I mean the compiler already knows it's an object, I'm sure the compiler can be trained not to complain about it. But then again by omitting it, I get an error message "statically allocating instance of objective-c class NSObject" What purpose would that serve?

Edit
Report

1 Answer

1

This is effectively a dupe of Why [object doSomething] and not [*object doSomething]?, which has a ton of background information.

answered 2010-12-15T20:59:57.343

Your Answer