如果我的对象基本上是一个看起来像这样的矢量容器:
std::vector<Base*> programs; //let's say in header file vector container would be defined like this
Box::box{
Base * a = new derived1(100);
Base * b = new derived2(100);
programs.push_back(a);
programs.push_back(b);
};//and it goes on, etc.
当我在main中创建时:
Box *ptr = new Box;
然后我想知道如何访问属于其成员的公共函数,让我们说类derived1?它甚至可能吗?