title: C++ CLI Class problem
body: <p>----- hello, world 2.cpp -----</p>
  
  <pre><code>// Hello, World 2.cpp : main project file.
  
  #include "stdafx.h"
  #include "hello.h"
  #include &lt;string&gt;
  
  using namespace System;
  using namespace std;
  
  int main(array&lt;System::String ^&gt; ^args)
  {
      hello hi = new hello("Bob", "Blacksmith");
      Console::WriteLine(L"Hello, " + hi.getName + "!");
      return 0;
  }
  </code></pre>
  
  <p>----- hello.h -----</p>
  
  <pre><code>#include &lt;string&gt;
  using namespace std;
  
  #ifndef HELLO_H
  #define HELLO_H
  
  class hello
  {
  private:
      string _fname;
      string _lname;
      //hello() { } // private default constructor
  
  public:
      hello(string fname, string lname);
      void SetName(string fname, string lname);
      string GetName();
  
  };
  
  #endif
  </code></pre>
  
  <p>----- hello.cpp -----</p>
  
  <pre><code>#include "stdafx.h"
  #include "hello.h"
  #include &lt;string&gt;
  using namespace std;
  
  hello::hello(string fname, string lname)
  {
      SetName(fname, lname);
  }
  
  void hello::SetName(string fname, string lname)
  {
      _fname = fname;
      _lname = lname;
  }
  
  string hello::getName()
  {
      return _fname + _lname;
  }
  </code></pre>
  
  <p>----- The errors -----</p>
  
  <ul>
  <li>------ Build started: Project: Hello, World 2, Configuration: Debug Win32 ------</li>
  <li>Hello, World 2.cpp</li>
  <li>Hello, World 2.cpp(12): error C2440: 'initializing' : cannot convert from 'hello *' to 'hello'</li>
  <li>No constructor could take the source type, or constructor overload resolution was ambiguous</li>
  <li>Hello, World 2.cpp(13): error C2039: 'getName' : is not a member of 'hello'</li>
  <li>\documents\visual studio 2010\projects\cpp\hello, world 2\hello, world 2\hello.h(8) : see declaration of 'hello'</li>
  <li>hello.cpp</li>
  <li>hello.cpp(17): error C2039: 'getName' : is not a member of 'hello'</li>
  <li>\documents\visual studio 2010\projects\cpp\hello, world 2\hello, world 2\hello.h(8) : see declaration of 'hello'</li>
  <li>hello.cpp(19): error C2065: '_fname' : undeclared identifier</li>
  <li>hello.cpp(19): error C2065: '_lname' : undeclared identifier</li>
  <li>Generating Code...
  ========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========</li>
  </ul>