=运算符重载
例:
shape obj;
shape obj1;
obj = obj1;
就是当有=操作时,会有重载的操作

解决方案 »

  1.   

    shape& operator=(const shape& s)表示重载运算符=
      

  2.   

    shape& operator=(const shape& s)表示重载运算符=
    光说这个我不明白啊! 我都看了好多文章了,还是不明白。
      

  3.   

    shape& operator=(const shape& s) 
    运算符进行重载。
    现在可以进行此对象的加法。并且,为了速度,进行的都是引用调用,返回值引用加上一条,const修饰的是=的右值,右值不变
      

  4.   


    class shape
    {
    shape& operator=(const shape& s)  //shape a = b;其中,我们可以这样子来认为,a.operator=(b),this指针指向她本身

    x_pos = s.x_pos; 
    y_pos = s.y_pos; 
    color = s.color; 
    return *this; 

    };
      

  5.   

    LZ,不要想那么复杂,
    大概看到
    shape obj; 
    shape obj1; 
    obj = obj1; 就是有2个对象有“=”操作时候,就执行
    {
    x_pos = s.x_pos; 
    y_pos = s.y_pos; 
    color = s.color;
    ....
    }
      

  6.   

    operator是操作符。+, -, =等等等等都是operator.
    程序中在+, -, *这些符号前面加了"operator",表示要重新定义这个操作符。
    比如说,int型的+表示两个数相加,1+1的结果等于2.你可以重新定义,让它等于3.(当然,int的+是不能重载的, 自己写的类可以)