What does this mean in practice?
This means that the second method returns by value, i.e. makes a copy of the array element / double and returns that copy to the caller. The first method returns a by-reference, i.e. It does not make a copy of the double, but rather returns a link to the source / binary location, which the calling code can then use to directly access the internal, double array if it wants. (if this helps, the semantics of the indirectness of the returned link are somewhat similar to the semantics of the pointer, with the exception of the syntax, which is more like the traditional C / C ++ function function)
When will I use one, and when will I use another?
The by-value method is safer because the probability of using undefined is less; the backlink method gives you additional flexibility (i.e., the caller can then update the element in the array, writing down the link it received as the return value), and in some situations it can be more efficient (for example, returning the link avoids having to copy the object, which can be an expensive operation if the object is large or complex). For a small object such as double, returning by value is probably more efficient than returning by reference.
How dangerous is [link method]?
This could be, for example, if you must return a reference to an automatic / stack variable, which will lead to undefined behavior, since the variable will be destroyed before the call code can use it:
double & dont_ever_do_this() { double x = 5.0;
Similarly, in your MyClass example, if the caller holds onto the returned link and then tries to use it after deleting myarray, the caller will read (or write) a memory location that is no longer valid, and this will result in undefined behavior (read: Bad Things).
And, of course, returning a non-constant reference means that the caller has the ability to change the contents of the returned element of the array, even if your class does not know about it, which may not be what you want to allow.