title: error: conversion from 'const char [5]' to non-scalar type in c++
body: <pre><code>public:
      string str;
  
      Test(string&amp; str){
          this-&gt;str=str;
          cout&lt;&lt;&quot;constructor&quot;&lt;&lt;endl;
      }
   
  
  };
  
  int main() {
      Test t=&quot;test&quot;;
      return 0;
  }
  </code></pre>
  <p>In this code I get the error <code>&quot;..\src\Test.cpp:30:9: error: conversion from 'const char [5]' to non-scalar type 'Test' requested &quot;</code>?</p>
  <p>Why is then the following code ok?</p>
  <pre><code>#include &lt;iostream&gt;
  using namespace std;
  
  class Test{
  
  public:
      string str;
  
      Test(string str){
          this-&gt;str=str;
          cout&lt;&lt;&quot;constructor&quot;&lt;&lt;endl;
      }
  
      Test(const Test &amp;test){
          cout&lt;&lt;&quot;copy constructor&quot;&lt;&lt;endl;
          this-&gt;str=test.str;
      }
  
  };
  
  int main() {
      Test t=Test(&quot;test&quot;);
      return 0;
  }
  </code></pre>