The std::string class allows assigning its internal value from different types, such as 'char', 'const char*' and 'std::string', with the help of this operator. Which operator is needed to be overloaded in order to achieve the following?
class A {
public:
A(std::string value)
: m_value(value)
{
}
// A a = std::string("some value")
A& operator=(const std::string value) {
m_value = value;
}
// std::string someValue = A("blabla")
???? operator ????
private:
std::string m_value;
};
After that, we should be able to access std::string's functions through the A object, for example:
A a("foo");
printf("A's value: %s \n", a.c_str());