摘要:
#include #include using namespace std; int main() { string str1 = "hello"; string* str2 = new string("hello"); string str3 = "world"; //获取字符串长度 int length = str1.length(); c... 阅读全文
摘要:
1.有时候希望赋值运算符两边的类型可以不匹配,比如说char*类型的字符串赋值给字符串对象 2.赋值运算符“=”只能重载为成员函数 3.深拷贝和浅拷贝 4.运算符重载为友元函数 成员函数不能满足要求,普通函数又不能访问私有成员变量 成员函数只能满足c=c+5,不能满足c=5+c;后者需要重载为友元函 阅读全文