Have I forgotten this thread?
Okidoky.
You won't get full code from me. That hard part you will do. But here is a nice visualisation:
Suppose the String is "Hello world.".
And the sub-string is " world".
The final result is "Hello.".
Let's see how it looks in memory:
Code:
[H][e][l][l][o][][w][o]r[l][d][.][\0] <==m_pChars, len = 12
[][w][o][r][l][d][\0] <== substring (to remove), sublen = 6
[][w][o][r][l][d][.] <== const char* firstoccurence = strstr(m_pChars, substr.m_pChars);
std::size_t pos = first - m_pChars; // First occurance position.
char* buffer = new char[len - sublen + 1];
//some magic here...
//delete[] m_pChars;
//Let m_pChars point to buffer
See if you can combine this information into a working part.
And if your teacher told you to overload operator-= for a custom string, tell him he should come here for a few lessons. By me.