[cpp] 关于模板
ling
xl-yc-lzj at necsoft.com.cn
Mon Jul 31 14:24:19 CST 2006
c++编程思想的一道习题,下面的代码中,
HardLogic的compare函数会报错,但是SoftLogic的
compare函数却不报错,这是为什么呢?
class Noncomparable { };
struct HardLogic {
Noncomparable nc1, nc2;
void compare() {
return nc1 = nc2;
}
};
template<class T> struct SoftLogic {
T nc1, nc2;
void noOp() {}
void compare() {
return nc1 = nc2;
}
};
int main()
{
SoftLogic<Noncomparable> l;
l.noOp();
}
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://codingnow.com/pipermail/cpp/attachments/20060731/23b9996d/attachment.html
More information about the Cpp
mailing list