我有一个用C ++定义的类型:
class MyTypeT
{
public:
MyTypeT();
virtual ~MyTypeT();
/// Initialize from string
bool fromString(const std::string &typeinfo);
/// Write to string
virtual std::string toString() const;
/// Is instance empty (not initialized yet)
bool empty() const;
};
我正在考虑像这样重载赋值运算符:
MyTypeT & MyTypeT::operator=(const std::string & rhs)
{
fromString(rhs);
return *this;
}
这是允许的有用方法还是有任何副作用?