使用以下實現初始化這些自定義(而非STL)列表對象時遇到困難。 Graph類包含一個指向自定義List對象的指針數組。我敢肯定,我錯了我的聲明我的列表數組。初始化指向對象的指針數組中的對象
片段的頭信息:
class Graph
{
private:
List **lists;
int listCount;
public:
.......
.......
}
片段實現的:
//node integer is used for size of array
void Graph::setLists(int node)
{
listCount = node;
lists = new List[listCount];
//for is used to initialized each List element in array
//The constructor parameter is for List int variable
for(int i = 0; i < listCount; i++)
lists[i] = new List(i);
}
錯誤我越來越:
Graph.cpp: In member function ‘void Graph::setLists(int)’:
Graph.cpp:11:28: error: cannot convert ‘List*’ to ‘List**’ in assignment
什麼是'List'應該做什麼和'Graph'應該做什麼? – rwols