我有這個函數讀取一個文本文件並將字符串發送到一個數組,然後從該函數發送該數組和元素數到我的構造函數。現在我的構造函數創建一個動態二維數組(我希望)。我想我的二維數組的行和列從接收的數組中分配值。使一個數組的內容變成另一個二維數組rows和colums
繼承人我的構造函數。
Graph::Graph(string cities[], int n)
{
this->nrOfCities=n;
this->x=n;
this->y=n;
this->graph=new string *[x];
for (int i = 0; i < x; i++)
this->graph[i] =new string[y];
for(int i=0;i<this->x;i++)
for(int j=0;j<this->x;j++)
this->graph[j]=NULL;
for(int i=0;i<=this->x;i++)//I know this last part doesn't work.
for(int j=0;j<this->x;j++)
this->graph[0][j+1]=cities[j];
}
任何形式的幫助表示讚賞。
什麼是第二外在做?如果你不使用我?也是第三外。 – atoMerz 2011-05-07 17:41:13