virtual assignment
<p>I'm having some trouble understanding this issue.</p>

<p>I have a class:</p>

<pre><code>class StringProperty { //snipped...
protected:
    std::string s;
public:
    virtual StringProperty& operator= (const std::string &x) {
        s = x;
        return *this;
    }
    virtual StringProperty& foo(const std::string &x) {
        s = x;
        return *this;
    }
};
</code></pre>

<p>This class (which have more methods and were snipped for simplicity) should act as a string.</p>

<p>When I derive from it:</p>

<pre><code>class Test : public StringProperty { };
</code></pre>

<p>I want to do something like this:</p>

<pre><code>Test x;
x = "test";</code></pre>

<p>However, this fails miserably (does not compile):</p>

<pre><code>error: no match for ‘operator=’ in ‘x = "test"’</code></pre>

<p>Nonetheless, if I use</p>

<pre><code>x.foo("test");</code></pre>

<p>It works.
I'm interested in understanding why it fails, since for me both functions are identical.</p>

<p>Thanks.</p>
