查看单个帖子
  #3 (permalink)  
旧 2008-02-21
mjus mjus 当前离线
初级会员
 
注册日期: 2006-11-18
住址: chn
帖子: 8
mjus 正向着好的方向发展
默认 回复: Marco or trait or something magic ?

>>why this can't be defined as a function template for DB?
>>//inside class definition
>>template<typename T>
>>bool insert(T x){ return insert(x.id, x); }


My point here is that the template class DB is provided with a generic type
, keyType and that the template class DB is served as a library. Therefore,

if the function template above is defined inside the class, because of its
hardcode, then the class DB can not be served as a library.

The recordType is limited to a POD type, that is the keyType must be one of
(int, long, double, and char*) only.
回复时引用此帖