Hello all, I am still trying to write a graph program! Unfortunately, I am not getting the error that name is not a member of listVertex[i], even though it is (or at least it should be)... and I have no idea why that is happening.
I've posted the relevant code below. I would be grateful if someone could point out why this isn't working.
in main()
1 2 3 4 5 6 7 8 9
else{
for(int i = 0; i<8; i++){//only 8 vertices in my map.txt
myFile >> Vertext;//string
cout << "start: " << Vertext<< endl;
roadMap.addVertex(Vertext);
cout<<"just added new Vertext" << endl;
}
roadMap.printGraph();
void Graph<DataType, KeyType>::addVertex(string name){
Vertext vert(name);
listVertext.push_back(vert);
}
void Graph<DataType, KeyType>::printGraph(){
cout<<"PRINTING GRAPH" <<endl;
for(int i=0; i<8; i++){
cout<<"CITY NAME: " << listVertext[i].name <<endl;
//saying there is no name for this and i have no clue why it isn't
//working.
}
}
@shadow fiend name is defined in line 36. I thought the fact that it is defined after its first use might have something to do with it, so we moved the constructor's definition from the .h file to the .cpp file. That way, when it defines that constructor, it should already know what name is, but we're still getting the same problem even after we've done that.