Chinaunix首页 | 论坛 | 博客
  • 博客访问: 542699
  • 博文数量: 493
  • 博客积分: 2891
  • 博客等级: 少校
  • 技术积分: 4960
  • 用 户 组: 普通用户
  • 注册时间: 2010-03-17 17:11
文章分类

全部博文(493)

文章存档

2010年(493)

分类:

2010-05-12 19:05:56

           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()
...
阅读(202) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~