Usually EscapedString es2 = es; calls the copy constructor, however you explicitly told it not to explicit copy the constructor:
explicit EscapedString(const EscapedString &strEscaped)
A constructor labeled explicit never be called using automatic type conversions. It can be called, but ... obviously, what you did here:
EscapedString es(EscapedString("Abc?def"));
This is what happens when the compiler encounters EscapedString es2 = es; .
First, the compiler sees if it can use the copy constructor and discovers that it cannot, since it was explicit marked. Therefore, he is looking for another constructor to call. Since EscapedString is derived from std::string , the compiler can use es as const std::string& and call:
EscapedString &operator=(const std::string &strUnEscaped)
source share