0
我想創建一個動態數組對象,使用靜態變量作爲指向下一個可用數組索引的指針。我敢肯定有更好的方法來做到這一點...使用靜態成員變量來計算創建的對象數
類存儲動態數組:
import std.stdio;
import DataRow;
class Database{
public:
this(){ /* intentionally left blank */}
void addRow(DataRow input){
this.db[count] = input;
writeln(count);
count++;
}
private:
static uint count;
DataRow[] db;
}
那裏只會有一個數據庫對象,就像一個Singleton。但是,就像你說的那樣,我是以錯誤的方式去做的。 – StillLearningToCode 2015-04-05 21:39:44