别拿浅拷贝不当拷贝

咱们知道C++中类里的成员函数中构造函数和拷贝构造都是值拷贝,因此地址也是值拷贝,也就是多个对象用到了一样的一块地址,例如:ios #include <iostream> using namespace std; class String { public:     String(char* str)     :_str(new char[strlen(str)+1])     {       
相关文章
相关标签/搜索