I come from a Java background, where EVERYTHING is a pointer, I've been having some trouble getting my head around * and & in c++. It's not easy to google this sort of thing because I'm pretty sure google ignores special characters.
I know & is along the lines of "reference of" and * is along the lines of "pointer", I'm still not sure in which situation I should be using a & or *, I've tried swapping them out and I get near the same results. In the small mini game I've been working on to learn c++ I've mostly been using * all around to designate that I want to use a pointer, and not create copies of the object, I just want to store the pointer in a different variable, but looking at sample code I've found on the internet it seems I am doing it incorrectly.
I would appreciate it if someone could either post me to a good article that talks about & and *, or at least maybe give me a quick run down on what the purpose of these operators are exactly
When I talk about these sort of assignments I mean stuff like
MyClass* varname;
MyClass& varname;
btw is there a difference between defining with
MyClass* varname
versus
MyClass *varname;
(looking at the location of the *).
edit: btw when I say that I see "sample code" using & where I would use * I mean like on this page
http://www.cplusplus.com/reference/stl/vector/vector/
the parameters use &, in my own code I have been using *, but achieving the effect that I desire (or at least I think I am), I am thinking there is some difference in the details that will come back and hurt my down the road.
thanks