2012-04-29 3 views
4

복사 없음 : 다른 곳통화에 대해 일치하는 기능은 내가 누구의 복사 생성자 같이 Graph.h에 선언 된 클래스 그래프가 생성자

template<typename Object,typename Weight>    
Graph<Object,Weight>::Graph(Graph<Object,Weight>& G) 

을, 나는 그것을 사용하려고 :

Graph<double,double> G = make_graph("dense.g"); 

...하지만 그것은 다음과 같은 오류가 발생합니다 :

 
time_trialsALIST.cpp:37: error: no matching function for call to `Graph::Graph(Graph)' 
Graph.h:142: note: candidates are: Graph::Graph(Graph&) [with Object = double, Weight = double] 

나는 이것이 일어날 이유를 모르겠다;

Graph<double,double> make_graph(string filename){...} 

은 내가 '&이'장소가 필요할을 수행하십시오 make_graph 기능은 그래프를 반환?

+0

가능한 복제본 [C++ Templates : 암시 적 변환, ctor 호출과 일치하는 함수 없음] (http://stackoverflow.com/questions/2628646/c-templates-implicit-conversion-no-matching-function-for- call-to-ctor) – outis

답변

5

Read the answer here. 즉 const이 누락되어 있고 &이 아닙니다. 확인하십시오 :

template<typename Object,typename Weight>    
Graph<Object,Weight>::Graph(const Graph<Object,Weight>& G) 

임시가 아닌 참조로 바인딩 할 수 없습니다.