views:

127

answers:

2

Possible Duplicate:
Placement of the asterisk in Objective-C

Could someone please shed some light as I am a bit confused as to the proper use of the indirection operator.

Example:

NSAutoReleasePool * pool = [[NSAutoReleasPool alloc] init];

MyAwesomeClass *awesomeClass;

So as I see them; are they just stylistic differences on declaring the object or does leaving a space between the operator and the variable name actually do something different?

THANKS for participating ...

+4  A: 

No difference. Purely style.

Here are some of the ways people read them differently:

CType* myVar; // the type of myVar is "CType-Pointer"
CType *myVar; // myVar is a Pointer-to-CType
CType * myVar; // This is a CType, referenced by a Pointer.

They are all 100% equal. But people tend to develop different "mental models" about how they read and think about pointers.

abelenky
Thanks for the clarification. Sometimes it is difficult to see the forest for the trees as they say. Now I understand the difference.
djt9000
+2  A: 

White space does not matter for pointer declarations. The following are all equivalent:

MyAwesomeClass *awesomeClass;
MyAwesomeClass* awesomeClass;
MyAwesomeClass * awesomeClass;
Peter Nix
Thank you, it was just a bit confusing and was wondering if there was a subtle difference in declarations.
djt9000