이 같은 몇 가지 다른 게시물을 알고 있지만 한 시간 이상이 오류가 있었고 그것을 알아낼 수 없습니다. 여기에 여기에 문제가C++ 오류 설명 할 수 없음 : 오류 : '&'토큰 앞에 예상 된 이니셜 라이저
istream& operator>>(istream& in, UndirectedGraph& g)
{
int numVerticies;
in >> numVerticies;
g = UndirectedGraph(numVerticies);
for(int i = 0; i < numVerticies; i++)
{
int temp;
in >> temp;
if(temp != i)
{
g.linkedAdjacencyList[i]->value = temp;
}
}
int edges;
in >> edges;
g.edges = edges;
for(int i = 0; i < edges; i++)
{
int first;
int second;
in >> first >> second;
addEdge(first, second);
}
return in;
}
ostream& operator<<(ostream& out, UndirectedGraph& g)
{
out << g.numVerticies << endl;
for(int i = 0; i < g.numVerticies; i++)
{
out << g.linkedAdjacencyList[i] << " ";
}
out << endl;
out << g.edges << endl;
for(int i = 0; i < g.numVerticies; i++)
{
out << linkedAdjacencyList[i]->value;
Node* whereto;
whereto = linkedAdjacencyList[i]->adj;
while(whereto->adj != NULL)
{
out << " " << whereto->value;
whereto->adj = whereto->adj->adj;
}
}
return out;
}
int main()
{
ifstream inFile;
inFile.open("hw8.in");
UndirectedGraph graph;
inFile >> graph;
...
을주고 코드입니다, 오류가 IStream을하고 ostream에의 과부하로, 라인 1, 28에 있습니다.
도움 주셔서 감사합니다. void
및 UndirectedGraph::istream&
:
라인 (1) 및 (28)는 무엇인가? –
@Daniel istream과 ostream 선언 – jlehenbauer