Returning a reference to a dummy character for indices beyond the string length (in operator[]).
This commit is contained in:
parent
14831247bc
commit
1362ca26c1
|
@ -194,7 +194,11 @@ int String::operator>=( const String & rhs ) const
|
||||||
|
|
||||||
char & String::operator[]( unsigned int index )
|
char & String::operator[]( unsigned int index )
|
||||||
{
|
{
|
||||||
// need to check for valid index, to do later
|
static char dummy_writable_char;
|
||||||
|
if (index >= _length || !_buffer) {
|
||||||
|
dummy_writable_char = 0;
|
||||||
|
return dummy_writable_char;
|
||||||
|
}
|
||||||
return _buffer[ index ];
|
return _buffer[ index ];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue