I'm still screwing on with a simplified string class, "Str,"which originated from a chapter of "Accelerated C++" and which I'm adding to for exercise questions (and my own amusement). Here is the problem: I have a constructor which converts a const char to a Str. The + operator is overloaded for Str. Therefore I can add a const char to a Str. It broke as soon as I added a conversion to bool for the purposes of using a Str as a condition. Now, I can't add a const char to a Str because the compiler complains thus (I'm paraphrasing):
So it seems that since I now have a conversion from Str to Bool, there's an ambiguity because the compiler could theoretically pass the bool as an int to the 2nd overload. I was for some unknown reason under the impression that C++ didn't convert from bool to int, but there it is anyway. My question is, what can I do to fix it?error C2666: 'operator +' : 2 overloads have similar conversions
could be 'Str operator +(const Str &,const Str &)'
1> or 'built-in C++ operator+(int, const char [6])'