title: Forward "Pre-declaring" a Class in C++
body: <p>I have a situaion in which I want to declare a class member function returning a type that depends on the class itself. Let me give you an example:</p>
  
  <pre><code>class Substring {
      private:
          string the_substring_;
      public:
          // (...)
          static SubstringTree getAllSubstring(string main_string, int min_size);
  };
  </code></pre>
  
  <p>And SubstringTree is defined as follows:</p>
  
  <pre><code>typedef set&lt;Substring, Substring::Comparator&gt; SubstringTree;
  </code></pre>
  
  <p>My problem is that if I put the SubstringTree definition after the Substring definition, the static method says it doesn't know SubstringTree. If I reverse the declarations, then the typedef says it doesn't know Substring.</p>
  
  <p>How can I do it? Thanks in advance.</p>