0
我有以下功能意外分段故障
bool Graph::termination_condition() {
for(int i = 0; i < nodes; i++) {
// check if any pair of neighbors is using the same color
//vector<int> neigh_colors;
//for(int idx = 0; idx < degree(node); idx++) {
// adjList[node][idx] is the neighbor
//if(find(neigh_colors.begin(), neigh_colors.end(), node_obj[adjList[node][idx]].l_color) == neigh_colors.end() )
// // not found, add
//neigh_colors.push_back(node_obj[adjList[node][idx]].l_color);
//else
// return false;
//}
// check if the color of the node is used
//if(find(neigh_colors.begin(), neigh_colors.end(), node_obj[node].l_color) != neigh_colors.end() )
// return false;
// check if color of node is in conflict list
//if(node_obj[node].tmp_conf_list.size())
// if(find(node_obj[node].tmp_conf_list.begin(), node_obj[node].tmp_conf_list.end(), node_obj[node].l_color) != node_obj[node].tmp_conf_list.end())
// return false;
}
return true;
// return false;
}
,使分段錯誤,每當我把它叫做
void Graph::otherfunction() {
if(termination_condition() == true)
return 1;
}
可能是什麼問題呢?
由於
UPDATE:
int Graph::otherfunction() {
if(termination_condition() == true)
return 1;
}
「節點」在哪裏申報?爲什麼`terminate_condition`中的所有註釋掉的代碼? – 2011-01-24 22:58:00
`otherfunction`甚至不能編譯,你不能``返回1;``void``函數。 – 2011-01-24 22:58:09