I'm pretty new to C++ so this may be a trivial question:
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.
class X {
// ...
private: double m_Array[9];
public: double* GetArray() const { return m_Array; }
};
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?