You can only use std::string::operator+=
from within member functions of MY_STRING
. Outsiders cannot use it. You can't "promote" it with using
or anything.
That's what private inheritance means. Private inheritance is, in effect, the same as having a private member variable, just that syntax is different within the member functions of MY_STRING
.
To fix this you will either have to not use private inheritance, or write a forwarding function for those that you want to publish.
Also, your forwarding function seems unnecessarily complicated, try:
MY_STRING &operator+= (MY_STRING const &s)
{ std::string::operator+=(s); return *this; }
You don't want to return a const reference when called on a non-const object (and += doesn't make sense for a const object).