AttributeGrid::iterator iter = m_Attributesgrid.find(pAttribute->m_bCode);
if (iter != m_Attributesgrid.end())
{
//找到了重复的值
(*iter).second.push_back(pAttribute);
}
else
{
//没找到
AttributeArray array;
array.push_back(pAttribute);
AttributeGrid::value_type value(pAttribute->m_bCode, array);
if (True != m_Attributesgrid.insert(value).second)
{
//写失败
DELETE(pAttribute);
}
}
wLength -= pAttribute->GetAllFieldLength();
}
if (0 != wLength)
{
LOGWARN(" failed to Serialize Radius Message,Packet Out of order!");
return False;
}
}
4 经验总结:预防措施和规范建议
代码编写时要严谨,多考虑异常情况
5 备注
6 考核点
try….catch(…) throw
7 试题
int funcA()
{
int nRet = 0;
...
return nRet;
}
void funcB()
{
...
throw "exception";
}
对于这两个函数的调用,哪些比较合理(A、C)
A.
int nRet = funcA();
if (nRet)
{
...
}
else
{
...
}
B.
funcA();
...
C.
try
{
funcB();
...
}
catch(...)
{
...
}
D.
funcB()
...
阅读(231) | 评论(0) | 转发(0) |