Dangers of using implicit string conversion operator?

What are the dangers of using an implicit conversion operator string

in a custom string class?

class MyString
{
public:

   ...

   inline operator string() const { return str; }

private:
   std::string str;
};

      

+3


source to share


1 answer


The main "danger" of implicit conversions is basically that you can get unexpected conversions.



If your string class can logically be used as std :: string, I don't think there is a problem.

+3


source







All Articles