title: How do i use 'auto' in C++ (C++0x)?
body: <p>What do i have to do to this code to make it compile, it's braking around this line:</p>
  
  <p>auto val = what.getObject();</p>
  
  <pre><code>#include&lt;iostream&gt;
  using namespace std;
  
  class CUP{
      public:
          void whatsHappening(){}
  };
  
  class MUG{
      public:
          void whatsHappening(){}
  };
  
  class CupThrower{
      public:
          CUP cp;
          CUP getObject(){ return cp;}
  };
  
  class MugThrower{
      public:
          MUG mg;
          MUG getObject(){return mg;}
  };
  
  template &lt;typename T&gt; void whatsHappening(T what){
  
      auto val = what.getObject(); //DOES NOT COMPILE
      val.whatsHappening();
  }
  
  int main(){
      CupThrower ct;
      MugThrower mt;
      whatsHappening(ct);
      whatsHappening(mt);
      return 0;
  }
  </code></pre>
  
  <p>i am using VS2008 to compile.</p>