分析C++函数功能?

来源:百度知道 编辑:UC知道 时间:2024/05/27 00:31:01
SnmpSyntax& TimeTicks::operator=(const SnmpSyntax &in_val)//构造TimeTicks类成员函数operator的一个对象
{
if (this == &in_val) return *this; // handle assignement from itself

valid_flag = false; // will get set true if really valid
if (in_val.valid())
{
switch (in_val.get_syntax())
{
case sNMP_SYNTAX_UINT32:
// case sNMP_SYNTAX_GAUGE32: .. indistinquishable from UINT32
case sNMP_SYNTAX_CNTR32:
case sNMP_SYNTAX_TIMETICKS:
case sNMP_SYNTAX_INT32: // implied cast int -> uint
smival.value.uNumber =
((TimeTicks &)in_val).smival.value.uNumber;
valid_flag = true;
break;
}
}
m_changed = true;
return *this;
}

Simple Network Management Protocol (Snmp)

通用的(若干种符合类型的值都可以用的)赋值运算定义。
SnmpSyntax& TimeTicks::operator=(const SnmpSyntax &in_val)

if (this == &in_val) return *this; // 处理自己赋值给自己
valid_flag = false; // 初值假,成功时将为真
if (in_val.valid()) // 函数实参代入的数值若是合法数
switch (in_val.get_syntax()) //取这串东西做与语法分析判断数的类型
类型符合的则
{smival.value.uNumber = 。。。。。;
valid_flag = true;}

return *this; 送返值