What is the convention for the star location in reference variables?
- by Brett Ryan
Have been learning Objective-C and different books and examples use differing conventions for the location of the star (*) when naming reference variables.
MyType* x;
MyType *y;
MyType*z; // this also works
Personally I prefer the first option as it illustrates that x is a "pointer type of MyType".
I see the first two used interchangeably, and sometimes in the same code I've seen differing uses of both. I want to know what is the most common convention
It's been a very long time since I've programmed in C (15 years) so I can't remember if all variants are legal for C also or if this is Objective-C specific.
I'd prefer answers which state why one is better than the other, as how I explained how I read it above.