Розробка власного класу STRING

Курсовой проект - Компьютеры, программирование

Другие курсовые по предмету Компьютеры, программирование

#229; . (7), , , .

/ , FatalError (), .

, , , . :

 

TPString a,b,c;

a = b = c;

 

, :

 

(1)

(2)

(3)

(4)

(5)

(6)

(7)

(8)

(9)

(10)

(11)

(12)

(13)

(14)

(15)

(16)

(17)

(18)

(19)

(20)

(21)

(22)

(23) TPString &TPString:: operator+= (const TPString& part)

{

if (BuffLen< (len+1+part. len)) {

BuffLen=len+1+part. len;

char *ptr=new char [BuffLen];

strcpy (ptr,symb);

strcpy (ptr+len,part. symb);

ptr [BuffLen-1] =0;

delete [] symb;

symb=ptr;

} else {

strcpy (symb+len,part. symb);

}

len+=part. len;

return *this;

}

TPString &TPString:: operator+ (const TPString& part)

{

TPString temp (*this);

temp+=part;

return temp;

}

(1) += . TPString. onst . (3) . (4) . (5) . (6) (7) . (8) . (9) .

+ (18) . (20) . += . = .

Clear () “”

 

void TPString:: Clear ()

{

len=0;

if (symb! =NULL) symb [0] =\0;

}

 

: .

 

(1)

(2)

(3)

(4)

(5)

(6)

(7)

(8) void TPString:: TPdelete (int startpos, int count)

{

if (startpos>=len||startpos<0||count<0) return;

if (startpos+count>=len||count==0) count=len-startpos+1;

int st=startpos+count;

for (; st<=len; st++) symb [startpos++] =symb [st];

len=len-count;

}

: , (6). (3) (4) .

, .

 

(1)

(2)

(3)

(4)

(5)

(6)

(7)

(8)

(9)

(10)

(11)

(12)

(13)

(14)

(15)

(16)

(17)

(18)

(19)