0
我不知道爲什麼指針不能作爲引用傳遞給函數。也許我錯過了錯誤的重點。指針類型的類模板專門化中沒有匹配函數
class Point{
public:
Point(){}
};
template<typename KEY,typename VALUE>
class TemplTest{
public:
TemplTest(){}
bool Set(const KEY& key,const VALUE& value){
return false;
}
};
template<typename KEY,typename VALUE>
class TemplTest<KEY*,VALUE>{
public:
TemplTest(){}
bool Set(KEY*& key,const VALUE& value){
return true;
}
};
int main(){
Point p1;
TemplTest<Point*,double> ht;
double n=3.14;
ht.Set(&p1,n);
return 0;
}
錯誤:
no matching function for call to 'TemplTest<Point*, double>::Set(Point*, double&)'
no known conversion for argument 1 from 'Point*' to 'Point*&'
請幫幫忙,謝謝!
看 - HTTP ://stackoverflow.com/questions/14492523/no-known-conversion-from-pointer-to-reference-to-pointer – Bill 2013-05-04 23:23:55