简单的语法问题,送分的 String & operate =(const String &other);这是什么意思?怎么实例化 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 写出来呀,比如:String::String &..... 这是一个&操作符的重载也就是重载类String中的操作符&使它取得一个String型对象的地址去看看c++的操作符重载部分的书吧 问题是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;} 这种赋值符的重载函数只能是某个类的成员函数。比如:class String{String & operator =(const String &other);}String & operator = const String &other){ memberA = other.memberA;} sorry, 丢了点东西。这种赋值符的重载函数只能是某个类的成员函数。比如:class String{String & operator =(const String &other);}String & String::operator = const String &other){ memberA = other.memberA;} 如何用CHttpFile上传文件 【求助】vc 6.0 应用程序正常初始化(0xc015002)失败 关于对象 析构 的顺序 在FormView中怎么没有FlexGrid? 【求助】VC++绘制问题! 求助!自定义语法的效验方法。 创建文件夹? 求汇编牛人将这个汇编程序翻译成VC程序 难道没人解决我的问题吗! 请教哪里有将WAV文件转换为MP3文件的控件 在LISTVIEW中增加一行InsertItem的问题 关于Dao数据库表格的属性添加修改问题?
也就是重载类String中的操作符&
使它取得一个String型对象的地址
去看看c++的操作符重载部分的书吧
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;
}
class String
{String & operator =(const String &other);}String & operator = const String &other)
{ memberA = other.memberA;
}
这种赋值符的重载函数只能是某个类的成员函数。比如:
class String
{String & operator =(const String &other);}String & String::operator = const String &other)
{ memberA = other.memberA;
}