title: function return with custom defined managed class type
body: <p>I meet a problem when I'm using C++/CLI.
  I defined a class called Person, it's a simple class with gets and sets:
      #pragma once
      using namespace System;</p>
  
  <pre><code>namespace CLI
  {
      public ref class Person
      {
      public:
          Person();
          // gets and sets
      private:
          String^ name;
          int age;
      };
  }
  </code></pre>
  
  <p>Then I defined a matrix class with person:
      #pragma once
      #include "Person.h"
      using namespace System;</p>
  
  <pre><code>namespace CLI
  {
      // Next is the managed wrapper of Logic:
      public ref class Matrix
      {
      public:
          Matrix();
          Person^ getPerson(int i, int j)
          {
              return paa[i][j]; // no problem
          }
          void Destroy();
      private:
          array&lt;array&lt;Person^&gt;^&gt;^ paa;
      };
  }
  </code></pre>
  
  <p>It's very strange that if I move getPerson() function to .cpp, there will be errors.</p>
  
  <p>Here is the Matrix.h &amp; Matrix.cpp with errors:</p>
  
  <pre><code>// Matrix.h
  #pragma once
  #include "Person.h"
  using namespace System;
  
  namespace CLI
  {
      public ref class Matrix
      {
      public:
          Matrix();
          Person^ getPerson(int i, int j);
          void Destroy();
      private:
          array&lt;array&lt;Person^&gt;^&gt;^ paa;
      };
  }
  
  
  // Matrix.cpp
  #include "Matrix.h"
  
  CLI::Matrix::Matrix()
  {
      // init the matrix
  }
  
  Person^ CLI::Matrix::getPerson(int i, int j) // errors here
  {
      return paa[i][j];
  }
  </code></pre>
  
  <p>One of errors says "Undefined identifier: Person", and this error is point to the function return type. I tried to write "Person^ p = gcnew Person;" in the function body, there was no error.
  Another error says "The function definition is not compatible with the one in .h file"(I'm not using English version of VS, I translated the  message, may be not very accurate.)</p>
  
  <p>If I change the return type anything not custom defined, like int, String^, it's OK.</p>
  
  <p>Please let me know if any more information is needed.</p>