20 lines
400 B
C++
20 lines
400 B
C++
|
#include "Char.h"
|
||
|
#include <cstring>
|
||
|
|
||
|
|
||
|
|
||
|
Char::operator char() const
|
||
|
{ return _string._str->operator[](_index); }
|
||
|
|
||
|
Char& Char::operator=(char other)
|
||
|
{
|
||
|
auto data = new char[_string.size() + 2]; // space for new char & null-terminator
|
||
|
std::strcpy(data, _string.c_str());
|
||
|
data[_index] = other;
|
||
|
|
||
|
|
||
|
_string._str->operator--();
|
||
|
_string._str = new StringValue(data);
|
||
|
|
||
|
return *this;
|
||
|
}
|