An array of arrays is different from an array of pointers to arrays. In your case, you cannot return the correct type without the width of your array ( y ) being published in your public interface. Without this, the compiler does not know how wide each row of the returned array is.
You can try the following:
class Sample { public: static const int x = 8; static const int y = 10; typedef char Row[y]; Row *get2D(); private: char two_d[x][y]; };
source share