They are interchangeable, it's just however you prefer doing it. There is no performance difference that I know of, as they both are just sending a pointer to a memory address, it's just different syntax. I beleive the reference was added to the C++ language, and isn't valid in C, so that would make it a more C++ way to do it I guess. I think the reason they did this, was so people didn't get confused with passing pointers to arrays, and pointers to single objects around.
void Test(Actor* const actor){ cout << "Lets error this thing out!" << actor[2].CurState;}
What's to stop some moron from using it as an array instead of a pointer to a single element? Of course I know you wouldn't, but when sharing code, using the reference is much safer, because they won't have to guess if it's supposed to be an array or a pointer to a single object.
Also, there are a few more syntactical ways to do the same thing
actor->CurState;actor[0].CurState;*actor.CurState;(*actor).CurState;
These are just a few examples on how people write the code that does the exact same thing, different people have different coding styles. I would mostly stick to refrences though. I also come from a C background, but I stick to references in C++ unless I'm passing an array, it just makes more sense
.
--- Edit ---
Ps. Edit your post, and fix your tag!
[edited by - Ready4Dis on June 19, 2003 7:32:48 AM]