c++ 运算符重载
对于自定义数据类型的运算,需要对运算符进行重载
+运算符重载
成员函数运算符重载格式
类名 operator+(类名+&变量)
{
// Person temp;
// temp.m_A = this->m_A + p.m_A;
// temp.m_B = this->m_B + p.m_B;
// return temp;
}
全局函数运算符重载格式
类名 operator+(类名+&变量,类名+&变量)
{
// Person temp;
// temp.m_A = this->m_A + p.m_A;
// temp.m_B = this->m_B + p.m_B;
// return temp;
}