实例如下:
代码如下 | 复制代码 |
usingnamespacestd;
classString; ostream& operator<<(ostream &out,constString&s); //引用计数器类 classString_rep { friendclassString; friendostream& operator<<(ostream &out,constString&s); |
public:
代码如下 | 复制代码 |
String_rep(constchar*str ) :use_count(0) { if(str == NULL) { data =newchar[1]; data[0] =' |