首先,我在 Ford Bellman claas 的构造函数中初始化值
FordBellman::FordBellman() {
this->vertexCount=0;
this->vertexFirst=0;
this->edgeCount=0;
this->wage=0;
this->matrix=0;
this->distance=0;
this->predecessor=0;
}
接下来我在 FordBellman 的初始化方法的参数中有参考
void FordBellman::initialize(const AdjacencyMatrix &am)
{
this->vertexCount=am.getVertexCount();
this->vertexFirst=am.getVertexFirst();
this->edgeCount=am.getEdgeCount();
this->wage=am.getWage();
this->matrix=am.getMatrix();
cout << vertexCount;
cout << vertexFirst;
.....
}
在主课上我这样做
int main() {
AdjacencyMatrix am;
FordBellman fb;
am.createFromFile("matrix.txt");
fb.initialize(am);
}
如果我调用 fb.initialize(am) 控制台什么都不显示(应该显示 cout)你能告诉我我做错了什么吗?