First off, before I started this program, Id never made a class in c++ just to give you an idea of my competency level, though I know java backwards and forwards.
adjacencyList is a 2d array of pointers to Vertices. This function prints out the weight of the row in the first loop perfectly. After "testing row" prints, I get a segfault.
My only working theory is that the memory is going out of scope, but I dont think it should be working that way.
Code:
void Graph::addRow(int row[], int rowIndex){
for(int i = 0; i < vertexCount; i++){
adjacencyList[rowIndex][i] = new Vertex(row[i]);
cout<<(*adjacencyList[rowIndex][i]).getWeight()<<" ";
}
cout<<"testing row"<<endl;
for(int i = 0; i < vertexCount; i++)
cout<<(*adjacencyList[rowIndex][i]).getWeight()<<" ";
}
adjacencyList is a 2d array of pointers to Vertices. This function prints out the weight of the row in the first loop perfectly. After "testing row" prints, I get a segfault.
My only working theory is that the memory is going out of scope, but I dont think it should be working that way.