Hi I'm doing a project for school and I'm stuck on this particular function, whenever it runs the test I get this error:
malloc(): memory corruption (fast): 0x0981f018 ***
here is what i have so far:
string& string::operator+=(char ch)
{
_size += 1;
if(_capacity <= _size){
(*this).increase_capacity(1);
}
_data[_size - 1] = ch;
return (*this);
//_size += 1;//Check to see if these go before
//_capacity += 1;; // THIS COULD CAUSE t26 TO FAIL
}
string string::increase_capacity(int x){
if(_capacity <= _size){
x = 1;
_capacity += x;
}
return *this;
}
I don't know if the increase capacity function is right though, I don't think it is. Thanks in advance.