Firstly I initialize value in constructor in 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;
}
next I have reference in argument of initialize method in 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;
.....
}
in main class I do it in this way
int main() {
AdjacencyMatrix am;
FordBellman fb;
am.createFromFile("matrix.txt");
fb.initialize(am);
}
And if i call fb.initialize(am) console show nothing(should show cout ) Can you tell me what I do wrong ?
When I tried to run code from github repository about you sad I got segmentation fault. The reason was in the file FordBellman.cpp line 42. There you didn't allocate array but you used it.
The reason why you didn't see anything is in the fact your program is terminated before it prints something. To be accurate it's happening inside of am.createFromFile("matrix.txt");
Try to write memory allocation for predecessor
and I think your code will start working.
I'm a bit confused that you doesn't get message about segmentation fault. What development environment you use?