C++ class conversion possible?
<p>I have the following code:</p>

<pre><code>class B {
public:
    B(const std::string&amp; str):m_str(str) { }
    B(const B&amp; b):m_str(b.m_str) { }
    B&amp; operator=(const B&amp; b) { m_str = b.m_str; return *this; }
private:
    std::string m_str;
};

main()
{
    std::string a = "abc";
    B b(a);
}
</code></pre>

<p>class B belongs to the client.  I can't change it and I may not even know its specific name ("B" is simply an example); all I know is there's a client class that accepts a std::string for its constructor.  Now I want to change the type of "a" in main() from std::string to A, as defined below:</p>

<pre><code>class A {
public:
      A(const std::string&amp; str):m_str(str) { }
      A(const char *str):m_str(str) { }
      A(const A&amp; a):m_str(a.m_str) { }
      A&amp; operator=(const A&amp; a) { m_str = a.m_str; return *this; }

private:
      std::string m_str;
};
</code></pre>

<p>So now I have a new main():</p>

<pre><code>main()
{
    A a = "abc";
    B b(a);
}
</code></pre>

<p>This can't compile properly as it is.  Is there anything I can do without changing the new main()?  I can't change class B, and class A should not reference class B in any way.
Thanks!</p>
