【发布时间】:2011-02-28 05:44:42
【问题描述】:
我有以下课程
class Parent {
virtual void doStuff() = 0;
};
class Child : public Parent {
void doStuff() {
// Some computation here
}
};
我有一个带有以下签名的函数。
void computeStuff(std::vector<boost::shared_ptr<Parent> >);
如果我可以重构我的代码(包括函数签名),向函数computeStuff 传递指向Child 对象的指针列表的最佳方式是什么?
本质上,我想编译和运行下面的 sn-p 代码
std::vector<boost::shared_ptr<Child> > listOfChilds = getList();
computeStuff(listOfChilds);
【问题讨论】:
标签: c++ list inheritance vector shared-ptr