我想這是C#版本翻譯一些食人魔代碼,我遇到了一個問題:在C#中C++ const size_t的等價物是什麼?
const size_t nVertices = 8;
const size_t vbufCount = 3*2*nVertices;
float vertices[vbufCount] = {
-100.0,100.0,-100.0, //0 position
-sqrt13,sqrt13,-sqrt13, //0 normal
//...
-sqrt13,-sqrt13,sqrt13, //7 normal
};
基本上,常量爲size_t並不在C#中存在,const int的,不能用來聲明數組的大小。
我想知道如何聲明具有常量值的數組?
您不需要顯式編寫數組的大小,至少不用C++。 – leemes 2013-02-09 13:09:50
數組已經固定,所以沒有必要根據常量來設置其大小。 – David 2013-02-09 13:10:05