title: crosses initialization error in switch case statement
body: <p>I've got the following code:</p>
  
  <pre class="lang-cpp prettyprint-override"><code>Class A {
    public:
      A::A(const char* name):
        _name(name)
        {}
      virtual void doSomething();
    private:
      const char* _name;
  }
  
  Class B : public A {
    B::B(const char* name):
      A(name)
      {}
    void doSomething() {
      //do something
    }
  }
  </code></pre>
  
  <p>So far so good, but I've experiencing an error <code>crosses initialization of B* newB</code> in the following code:</p>
  
  <pre class="lang-cpp prettyprint-override"><code>std::vector&lt;A*&gt; vectorOfAs;
  
  switch (enumType) {
    case enum1 :  
      B* newB = new B("foobar");
      vectorOfAs.push_back(newB);
      break;
    case enum2 :
      C* newC = new C("barfoo");
      vectorOfAs.push_back(newC);
      break;
  }
  </code></pre>
  
  <p>Why the error?</p>
  
  <p>Some background:
  I want to store pointers of derived classes in a vector for easy searching/iterating. The names are unique so I can iterate through the vector and look for the pointer which points to the object with the right name. When calling a method from a pointed-to object, the inherited one should be called (<code>//do something</code>).</p>
  
  <p>Edit: @François Andrieux: you're right. made (serious) typo.
  Changed <code>Class B : public B</code> to <code>Class B: public A</code></p>