How to properly return an array (class member) in C++?
<p>I'm pretty new to C++ so this may be a trivial question:</p>

<p>My class has a private member variable that is an array. I need to return that array, but I'm not sure how to do that properly.</p>

<pre><code>class X {
    // ...
    private: double m_Array[9];
    public: double* GetArray() const { return m_Array; }
};
</code></pre>

<p>Is there any problem with this code? This returns a pointer to the class member, right? - so if I fetch that array from an instance of this class and modify it (from outside the class), the original class member array will get changed as well? If that is the case, how do I return a copy of the array instead?</p>
