class String{
private:
TCHAR* buffer;
int length;
public:
int getLength(){
return length;
}
String(TCHAR* string){
this->length=_tcslen(string);
int l=(length+1)*sizeof(TCHAR);
buffer=new TCHAR[l];
ZeroMemory(buffer,l);
if(buffer==NULL){
throw NULL;
}
_tcscpy(buffer,string);
}
String(){
buffer=NULL;
length=0;
}
String& operator+= (String& str){
int l=(this->getLength()+str.getLength())+1;
TCHAR* buf=new TCHAR[l*sizeof(TCHAR)];
if(buf==NULL){
throw NULL;
}
::ZeroMemory(buf,l*sizeof(TCHAR));
_tcscpy(buf,buffer);
_tcscpy((buf+getLength()),str.buffer);
buffer=buf;
return *this;
}
void print(){
::_tprintf(_T("%s\n"),this->buffer);
}
};