Need a new = operator for String

It would minimize one extra object if there would be also operator

const String & String::operator=( const char *st) { int len = strlen(st); if ( len > _length ) { free(_buffer); getBuffer( len ); }

if ( _buffer != NULL ) { _length = len; strcpy( _buffer, st ); } return *this; }

Otherwise in

String s; ... s = "dummy";

first is called constructor String(const char *) to make a string to substitute to s and then is called operator=(const String&) to substitute that string to s. So the text "dummy" created and copied twice.

;)

Please use the # button when submitting code.

BTW good point.