- 对于一个运算符函数来说,它或者是类的成员,或者至少是含有一个类型的对象。
 - 对箭头运算符来说,不
 
有不能重载的运算符?
有滴,请看以下重载规则:
- C++不允许用户定义新的运算符,只能重载已经有的重载运算符。
 - 不能重载的运算符有5个
 
- . 访问成员
 - .* 指针访问类成员运算符
 - :: 域运算符
 - sizeof 长度运算符
 - ? 条件运算符
 

不能重载的运算符

小总结
不知道你看到了吗,这儿没写sizeof()?
Sizeof cannot be overloaded because built-in operations, such as incrementing a pointer into an array implicitly depends on it. Consider:
    X a[10];
    X* p = &a[3];
    X* q = &a[3];
    p++;    // p points to a[4]
        // thus the integer value of p must be
        // sizeof(X) larger than the integer value of q
来了一个新成员 typeid
- 重载不能改变操作符所操作的个数的个数,(ps:感觉就像自定义拼图,不能多不能少)
 - 重载运算符不能改变操作符的优先级别(这也等级制度)
 - 重载运算符不能改变操作符的结合性
重要的东东: 

常用的
操作符的重载方式?
- 普通重载
 - 成员函数重载 赋值== 下标[] 调用() 成员指向->
 - 友元函数重载  需要访问类中的private数据时
重载prefix 和postfix 
C++ 约定:在自增(自减)运算符重载函数中,增加一个int型参数,就是后置自增(自减)
#include <iostream>
class example
{
public:
    int a;
    int b;
    example operator+(const example &obj);
    void operator=(const example &obj2);
    private:
};
example example::operator+  (const example &obj)
{
    example tmp_obj = *this;
    tmp_obj.a = tmp_obj.a + obj.a;
    tmp_obj.b = tmp_obj.b + obj.b;
    return tmp_obj;
}
void example::operator=(const example &obj2)
{
    (*this).a = obj2.a;
    (*this).b = obj2.b;
    return;
}
int main() {
    example obj1, obj2, obj3;
    obj1.a = 1;
    obj1.b = 2;
    obj2.a = 2;
    obj2.b = 3;
    obj3.a = 2;
    obj3.b = 6;
    obj3 = obj1 + obj2;
    std::cout << obj3.a << "  " << obj3.b << std::endl;
    system("pause");
    return 0;
}
输出:
3  5
ps(实现对象的对应成员相加,简直是矩阵相加啊~~)
[stackoverflow refrence ](Operator overloading)
Operator Overloading
看来stackoverflow 的干货很棒