首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >把麻烦插入书单

把麻烦插入书单
EN

Stack Overflow用户
提问于 2021-10-16 04:08:00
回答 1查看 29关注 0票数 0

我在这方面有点困住了。通过使用BookList.insert(book, Position::BOTTOM),我将得到在BookList上表示此错误的cquery

不能在类型上使用点运算符

我想不出有什么方法能比这更好地插入booklist

这可能是if声明的结果吗?我打算这样做“如果(流工作){插入到书单}”。

这是代码,在底部有一个指向代码图片的链接。

代码语言:javascript
复制
std::istream& operator>>(std::istream& stream, BookList& book_list) {
  if (!book_list.containers_are_consistent()) {
    throw BookList::InvalidInternalStateException(
        "Container consistency error in operator>>");
  }
  std::string label_holder;
  size_t count;

    // Read in data from a stream and use it to fill in the data of a BookList
    // object. Create a function that will read the output created by the
    // ostream operator above into an object properly.

  stream >> count;
  for (int i = 0; i < count; i++) {
      stream.ignore(100, ':');
    }
      if (stream) {
        BookList.insert(book, Position::BOTTOM);
    }
  return stream;
}

EN

回答 1

Stack Overflow用户

发布于 2021-10-16 04:18:21

我假设insert()BookList类的成员函数。如果这个假设是正确的,那么在使用.表示法时,必须对BookList实例而不是对类名本身调用它。因此,将其替换为:

BookList.insert(book, Position::BOTTOM);

有了这个

book_list.insert(book, Position::BOTTOM);

票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/69592566

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档