我不知道为什么不能将指针作为引用传递给函数。也许我错过了错误的重点。
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*&'
请帮忙,谢谢!