title: Why doesn't the compiler show an error with these return types?
body: <p>Running a default installation of Ubuntu 11.10 with the latest version of NetBeans. I have something similar to the following:</p>
  
  <pre><code>class MyClass {
      public:
          Type1 RunAlgo();
      private:
          Type2 Run();
  }
  
  Type1 MyClass::RunAlgo() {
      //additional code
      return Run();
  }
  
  Type2 Run() {
      //additional code
      Type2 obj;
      return obj;
  }
  </code></pre>
  
  <p>Type1 and Type2 are completely unrelated. I came upon this by making a typo in the return type when I was writing the Run() method and was amazed that it compiled. I am just wondering why this does not return an error and just compiles fine? What am I missing?</p>
  
  <p>EDIT: New sample. This does generate an error as a stand alone project. Can't seem to spot why the real project would indeed compile.</p>
  
  <pre><code>class Node { };
  
  //only difference here is that in my code I have a custom comparer
  typedef map&lt;Node*, map&lt;Node*, double&gt; &gt; Network; 
  
  class HMM {
      Network _network;
  };
  
  class Algorithm {
      public:
          HMM RunAlgo();
      private:
          Network _network;
          Network Run();
  };
  
  HMM Algorithm::RunAlgo() {
      return Run();
  }
  
  Network Algorithm::Run() {
      return _network;
  }
  </code></pre>
  
  <p>EDIT2:</p>
  
  <p>I apologize for my badly formulated question and example. I will be more careful in the future about examples. I've been working for a bit over 10 hours and lost focus. The following example reproduces my case:</p>
  
  <pre><code>#include &lt;map&gt;
  
  using std::map;
  
  class Node {
  
  };
  
  typedef map&lt;Node*, map&lt;Node*, double&gt; &gt; Network;
  
  class HMM {
      public:
          HMM(const Network&amp; network) {};
      Network _network;
  };
  
  
  class TestClass {
      public:
          HMM RunAlgo(int x, int y);
      private:
          Network _network;
          Network Run();
  };
  
  HMM TestClass::RunAlgo(int x, int y) {
      return Run();
  }
  
  Network TestClass::Run() {
      return _network;
  }  
  </code></pre>
  
  <p>After adding that specific constructor to the HMM class it compiles without problems. I didn't know this could be done as this is the first time I encounter this case. Again I apologize if I wasted your time and I appreciate you trying to help me.</p>