It turns out my original answer was completely wrong, but I canβt delete it from the moment it was accepted . Of the two separate answers below, I was able to compile this:
class Sample { const static int x = 8; const static int y = 2; public: typedef char SampleArray[x][y]; SampleArray& getArr(); void blah(int x, int y); private: SampleArray arr; }; Sample::SampleArray& Sample::getArr () { return arr; }
(I compiled my original solution only with the declaration of the OP class, and not with the definition of getArr() .)
Just return the pointer to the pointer.
char** getArr();
source share