title: Polymorphism without "new"
body: <p>Lets say I've got something like the following:</p>
  
  <pre><code>class A { virtual void g() = 0 }
  
  class B : public A { virtual void g() { ... } }
  class C : public A { virtual void g() { ... } }
  
  ... f(bool x)
  {
    if (x) { return B(); } else { return C(); }
  }
  
  bool get_boolean();
  
  int main()
  {
    bool b = get_boolean();
    ... x = f(b);
    x.g();
  }
  </code></pre>
  
  <p>Is there anyway to do something like the above without calls to <code>new</code>, i.e. solely on the stack? </p>