使用以下实现初始化这些自定义(非 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