首页 > 代码库 > 重写String类

重写String类

主要是4个默认函数的重写:

代码:

#include <iostream>

using namespace std;

class Cstring{
private :
	char * data;
public :
	Cstring(const char * str =NULL); 
	Cstring(const Cstring &another); 
	~Cstring();	

	Cstring & operator=(const Cstring &another);

	
};
//赋值构造函数
Cstring & Cstring::operator=(const Cstring &another){
	if(this  == &another)
		return *this;
	delete [] data;
	data = http://www.mamicode.com/NULL;>