title: Can anonymous class be used as return types in C++?
body: <p>Is there any way to use anonymous classes in C++ as return types?</p>
  
  <p>I googled that this may work:</p>
  
  <pre><code>struct Test {} * fun()
  {
  }
  </code></pre>
  
  <p>But this piece of code doesn't compile, the error message is: </p>
  
  <blockquote>
    <p>new types may not be defined in a return type</p>
  </blockquote>
  
  <p>Actually the code doesn't make any sense, I just want to figure out whether an anonymous class can be used as return type in C++.</p>
  
  <p>Here is my code:</p>
  
  <pre><code>#include &lt;typeinfo&gt;
  #include &lt;iterator&gt;
  #include &lt;iostream&gt;
  #include &lt;fstream&gt;
  #include &lt;cstring&gt;
  #include &lt;cstdlib&gt;
  
  using namespace std;
  
  int main(int argc, char **argv)
  {
      int mx = [] () -&gt; struct { int x, y ; } { return { 99, 101 } ; } ().x ;
      return 0;
  }
  </code></pre>
  
  <p>I compile this code with g++ xx.cpp -std=c++0x, the compiler compains:</p>
  
  <pre><code>expected primary-expression before '[' token.
  </code></pre>