I pretend to write a class which can act as a variant type. Everything is working fine, but when I try to assing a string, the method that gets called is the one with bool as a parameter:
class value_t {
public:
value_t operator=(const int& integer) {
std::cout<<"integer"<<std::endl;
return *this;
};
value_t operator=(const std::string& str) {
std::cout<<"string"<<std::endl;
return *this;
};
value_t operator=(const bool& boolean) {
std::cout<<"boolean"<<std::endl;
return *this;
};
};
value_t val;
val = "Hola mundo";
And the output is:
boolean
Why is not the string assign operator method get called?
Thank you