You are confusing C++ with Java. p1
is not a reference, it's just an object with automatic storage duration. It's created when the variable's scope begins, and it's destroyed when the variable's scope ends.
In C++, you normally only use the "heap" (the correct word would be: the free store) if you need more complex control over an object's lifetime.
If you don't need this special control, then an object in C++ works just like, say, an int
or a double
. You wouldn't feel it's necessary to write new int
or new double
, would you? Well, in C++, your player
acts like an int
or a double
in this regard. It's a major difference to almost all other popular programming languages.