I want to extend the std::string
with some functionality, so I derive my String
from it. In order to make code like String str = stdStr;
work, I've tried to overload the assignment operator, but my code is not being called for some reason. How can I fix it?
#include <string>
class String
:
public std::string
{
public:
/*
I do know that this constructor will solve the problem, but is it possible to use the operator?
String ( const std::string& stdString )
{
...
}
*/
String& operator= ( const std::string& stdString )
{
...
return *this;
}
};
int main()
{
std::string foo = "foo";
String bar = foo;
return 1;
}