I'm coming from Java and attempting to learn C++.
As far as I can tell, using Pointers is very similar to how reference variables work in Java, in that you pass a memory address to the value. So I feel like I have gotten a pretty good understanding of them. I also understand that these variables are stored on the heap.
However, I see that there is another way in which you can declare variables in C++, without the new operator/pointers simply doing something like:
Employee boss("Frank");
Which will create a value of Employee with "Frank" as the parameter. These variables are stored on the stack.
So, you have these 2 very different ways of creating variables and both with their own unique behavior (with memory management as well?).
My question is, when is it appropriate to use pointers VS values? What is the best practice? How should I know in what way I want to declare my variables most of the time?