Counter-intuitive behavior with virtual functions
<p>Given</p>

<pre><code>#include &lt;string&gt;
#include &lt;iostream&gt;


struct A  {
    virtual operator std::string() const { return "A"; }
    virtual operator const char *() const { return this-&gt;operator std::string().c_str(); }
};

struct B1 : public A {
    virtual operator std::string() const { return "&lt;"; }
};

struct B2 {
    B2() { }
    virtual ~B2() { }
    virtual operator std::string() const { return "&gt;"; }
    virtual operator const char *() const { return this-&gt;operator std::string().c_str(); }
};

struct C1 : public A {
    C1() { }
    virtual ~C1() { }
    virtual operator std::string() const { return "["; }
};

struct C2 {
    C2() { }
    virtual ~C2() { }
    virtual operator std::string() const { return "]"; }
    virtual operator const char *() const { return this-&gt;operator std::string().c_str(); }
};

int main() {
    using namespace std;
    cout &lt;&lt; B1() &lt;&lt; endl;
    cout &lt;&lt; C1();
    cout &lt;&lt; C2() &lt;&lt; B2() &lt;&lt; endl;
}
</code></pre>

<p>The output should be "&lt;[]>". However, it is "&lt;[]]".</p>

<ol>
<li>Am I wrong? If so, why?</li>
<li>If not, then what are the potential reasons for this behavior?</li>
</ol>
