min*_*cho 1 c++ arrays declaration header-files
我试图在我的头文件中声明一个返回2D数组的函数.考虑到我们已经知道阵列的大小,怎么能实现呢?以下是我目前正在做的事情.
class Sample
{
public:
char[x][y] getArr();
void blah(int x, int y);
private:
const static int x = 8;
const static int y = 2;
char arr[x][y];
};
Run Code Online (Sandbox Code Playgroud)
我认为你应该使用typedef.
typedef char TArray[2][2];
TArray& getArr();
Run Code Online (Sandbox Code Playgroud)