I have a class which looks like this :
class MyClass {
public:
void drawText(const QString& rText);
void drawText(const std::string& rText);
};
I overloaded the drawText()
method because I want to accept QString
as well as std::string
.
But when I write something like this :
MyClass foo;
foo.drawText("Hello");
The compiler is complaining that the call to drawText()
is ambiguous.
I understand that from an array of char, the compiler cannot decide between a QString
or a std::string
, because both provide a suitable constructor.
But is there a way for me to make sure the user can use the drawText()
method either by passing a QString
or a std::string
or an array of char ?