【发布时间】:2012-01-20 03:27:41
【问题描述】:
template<typename T> T SmartIO::Peek() {
T temp;
T tempReturn;
while(true){
temp = *(T*)&buffer[ptrSeek];
if(temp !=0){
ptrSeek++;
tempReturn += *(T*)&buffer[ptrSeek];
}
else{
break;
}
}
return tempReturn;
}
所以我想要做的是,从 ptrSeek 开始读取开始循环,将值添加到 temp 并检查 temp 的值是否!=0 将此值添加到 tempReturn,一旦 temp 的值为 0,就打破循环并返回tempReturnbut,但它一直给我这个错误:
error C2678: binary '!=' : no operator found which takes a left-hand operand of type 'std::basic_string<_Elem,_Traits,_Ax>' (or there is no acceptable conversion)
我该如何解决这个问题?
【问题讨论】: