int main() {
    //class B and C inherits from A
    vector<B> b;
    vector<C> c;
    vector<A*> a;
    {
        B b_temp;
        b.push_back(b_temp);
        C c_temp;
        c.push_back(c_temp);
        a.push_back(&b[0]);
        a.push_back(&c[0]);
        b.push_back(b_temp);//this will break a, since it will move the b vector. is there an efficent way to move the pointers with it?
        //pointer vector a's order is important
    }
    system("PAUSE");
    return 0;
};
当向所指向的向量添加新元素时b,它将扩展并分配新内存。然后指针向量a将指向坏内存。有没有重新指向先前向量的有效方法?
a指向几个不同的向量,它的顺序很重要。添加新元素时,我希望它保持相同的顺序并最后添加新元素。