title: conversion from 'std::string' to non-scalar type requested
body: <p>I have trouble implementing my class. It should be able to initialize from std::string. So I wrote a copy (?) constructor:</p>
  
  <pre><code>CVariable (std::string&amp;, const int p_flags = 0);
  </code></pre>
  
  <p>I'm trying to make an object of CVariable:</p>
  
  <pre><code>MCXJS::CVariable s_var = (string)"good job";
  </code></pre>
  
  <p>I'm getting the following error:</p>
  
  <pre><code>F:\Projekty\MCXJS\src\main.cpp|8|error: conversion from 'std::string' to non-scalar type 'MCXJS::CVariable' requested|
  </code></pre>
  
  <p>How to fix that?</p>
  
  <p><strong>I'M SEARCHING FOR SOLUTION THAT WILL ALLOW SOMETHING <em>EXACTLY</em> AS FOLLOWS:</strong></p>
  
  <pre><code>MCXJS::CVariable s_var = (string)"good job";
  </code></pre>
  
  <p>Edit: adding (almost) full source code:</p>
  
  <p>cvariable.h</p>
  
  <pre><code>#ifndef CVARIABLE_H
  #define CVARIABLE_H
  
  #include &lt;string&gt;
  #include &lt;sstream&gt;
  
  namespace MCXJS
  {
  enum VARTYPE
  {
      STRING = 0,
      INT = 1,
      FLOAT = 2
  };
  
  class CVariable
  {
      public:
      VARTYPE Type () {return m_type;};
      std::string&amp; Value () {return m_value;};
      bool SetType (VARTYPE);
  
      private:
      const int m_flags;
      VARTYPE m_type;
      std::string m_value;
  
      // ctors and operators
      public:
      CVariable (const int p_flags = 0);
      CVariable (CVariable&amp;, const int);
      CVariable (std::string const&amp;, const int);
      CVariable (const int&amp;, const int);
      CVariable (const float&amp;, const int);
  
      CVariable&amp; operator= (const CVariable&amp;);
      CVariable&amp; operator= (const std::string&amp;);
      CVariable&amp; operator= (const int);
      CVariable&amp; operator= (const float);
  };
  };
  
  #endif // CVARIABLE_H
  </code></pre>
  
  <p>cvariable.cpp</p>
  
  <pre><code>#include "cvariable.h"
  
  using namespace MCXJS;
  using namespace std;
  
  CVariable::CVariable (const int p_flags):
  m_flags (p_flags)
  {};
  
  CVariable::CVariable (CVariable&amp; p_var, const int p_flags = 0):
  m_flags (p_flags),
  m_type (p_var.Type()),
  m_value (p_var.Value())
  {};
  
  CVariable::CVariable (std::string const&amp; p_value, const int p_flags = 0):
  m_flags (p_flags),
  m_type (STRING),
  m_value (p_value)
  {};
  
  CVariable::CVariable (const int p_value, const int p_flags = 0):
  m_flags (p_flags),
  m_type (INT)
  {
  std::ostringstream buffer;
  buffer &lt;&lt; p_value;
  m_value = buffer.str();
  };
  
  CVariable::CVariable (const float p_value, const int p_flags = 0):
  m_flags (p_flags),
  m_type (FLOAT)
  {
  std::ostringstream buffer;
  buffer &lt;&lt; p_value;
  m_value = buffer.str();
  };
  </code></pre>
  
  <p>main.cpp</p>
  
  <pre><code>#include "cvariable.h"
  #include &lt;iostream&gt;
  
  using namespace std;
  
  int main()
  {
  MCXJS::CVariable s_var = (string)"good job"; // error
  cout &lt;&lt; s_var.Value() &lt;&lt; '\n';
  return 0;
  }
  </code></pre>
  
  <p>Edit: adding enum VARPARAM</p>
  
  <p>Edit: OK, solved above, now I have this:</p>
  
  <pre><code>cvariable.cpp|12|error: passing 'const MCXJS::CVariable' as 'this' argument of 'MCXJS::VARTYPE MCXJS::CVariable::Type()' discards qualifiers|
  cvariable.cpp|13|error: passing 'const MCXJS::CVariable' as 'this' argument of 'std::string&amp; MCXJS::CVariable::Value()' discards qualifiers|
  </code></pre>