String & operate =(const String &other);
这是什么意思?怎么实例化

解决方案 »

  1.   

    写出来呀,比如:String::String &.....
      

  2.   

    这是一个&操作符的重载
    也就是重载类String中的操作符&
    使它取得一个String型对象的地址
    去看看c++的操作符重载部分的书吧
      

  3.   

    问题是String类型是怎么定义的?这和该类型的结构有关。如:
    struct String
    {
      int len;
      char buf[100];
    }则可以:
    String & operate =(const String &other)
    {
       String str;
       str.len=other.len;
       strcpy(str.buf,other.buf);   return str;
    }
      

  4.   

    这种赋值符的重载函数只能是某个类的成员函数。比如:
    class String
    {String & operator =(const String &other);}String & operator = const String &other)
    {    memberA = other.memberA;
    }
      

  5.   

    sorry, 丢了点东西。
    这种赋值符的重载函数只能是某个类的成员函数。比如:
    class String
    {String & operator =(const String &other);}String & String::operator = const String &other)
    {    memberA = other.memberA;
    }