handwith 2015-12-10 09:08 采纳率: 0%
浏览 1382

关于C++primer第四版中message示例中中const_iterator的疑问

void Message::put_Msg_in_Folders(const set &rhs)
{
for(std::set::const_iterator beg = rhs.begin();
beg != rhs.end(); ++beg)
(*beg)->addMsg(this); // beg points to a Folder
}
个人对(*beg)返回值理解为(string * const &),只是不知道对不对,只有这样才能修改rhs中Foler
所指向的对象。rhs为const对象,则rhs不可增加或减少元素个数,rhs的元素也应为const,可上面程序就是改变了元素值,不能求理解,大侠帮忙解释一下。

  • 写回答

4条回答 默认 最新

  • oyljerry 2015-12-10 14:52
    关注

    这是迭代器本身不能改变 但是它指向对象是可以改变的

    评论

报告相同问题?