title: cannot convert from const char* to const char *&
body: <p>I am writing a simple UTF8 to WideStr function on VC++.</p>
  
  <p>MtoW.h</p>
  
  <pre><code>#pragma once
  #include &lt;Windows.h&gt;
  #include &lt;string&gt;
  using namespace std;
  wstring UTF8toWide(const char*&amp; in);
  </code></pre>
  
  <p>MtoW.cpp</p>
  
  <pre><code>#include "MtoW.h"
  #include &lt;string&gt;
  #include &lt;cassert&gt;
  using namespace std;
  wstring UTF8toWide(const char*&amp; in) {
      int size = MultiByteToWideChar(CP_UTF8, 0, in, -1, NULL, 0);
      wchar_t* wide_str = new wchar_t[size];
      int result_size = MultiByteToWideChar(CP_UTF8, 0, in, -1, wide_str, size);
      assert(size == result_size);
      return wstring(wide_str);
  }
  </code></pre>
  
  <p>main.cpp</p>
  
  <pre><code>#include &lt;string&gt;
  #include &lt;iostream&gt;
  #include "MtoW.h"
  using namespace std;
  int main()
  {
      string s = "hi";
      //s.c_str();
      //const char* q = "abc";
      //const char*&amp; c = q;
      wstring q = UTF8toWide(s.c_str()); //error 
  }
  </code></pre>
  
  <p>I got <code>cannot convert from const char* to const char *&amp;</code> error, why?<br>
  <code>s.c_str()</code> is a <code>const char*</code> type and my code should work.</p>