0
我有一个指向某个对象的指针的列表。 我想复制列表,但与新的指针。指针无循环的复制列表
我的意思是列表中的每个元素,做新的对象,并在新列表中插入新的地址。
我尝试使用:
std::list<Course*> tmp;
tmp = courses; // courses is list<Course*>.
std::for_each(tmp.begin(), tmp.end(), ReplaceAllCells());
class ReplaceAllCells {
public:
ReplaceAllCells(){}
void operator()(Course* course) {
course = new Course(*course);
}
};
后调用函数我得到同样的指针新的列表... TMP的值没有改变.. 我怎么能修复不使用任何循环? 谢谢。
您的'Shift'键是否损坏? – ooga
我有点像Froot循环。 –