Oh the joys of being a memory management noob !
I’m getting bit by some Objective-C code, eventhough I understand the basics of pointers, I’ve seen these two different constructs, without being able to really understand their difference.
Can anyone enlighten me ?
Edited my question, the constructs didn’t behave differently, instead I got bit yet again by the multiple declarations gotcha.
Thanks !
There’s no difference – it’s a matter of taste. However, beware that the pointer actually always binds to the name, not the type. So this:
Declares
var1as a pointer toType, whilevar2is not a pointer. That’s just one more reason not to declare multiple variables in the same statement.Historically, the
Type *varnotation is more common in C, where it is read as “varis declared as a pointer toType”, i.e. “the type of*varisType”. In C++, on the other hand,Type* varis more common and is read as “varis declared as being of type ‘pointer toType’”.