我在这方面有点困住了。通过使用BookList.insert(book, Position::BOTTOM),我将得到在BookList上表示此错误的cquery
不能在类型上使用点运算符
我想不出有什么方法能比这更好地插入booklist。
这可能是if声明的结果吗?我打算这样做“如果(流工作){插入到书单}”。
这是代码,在底部有一个指向代码图片的链接。
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;
}

发布于 2021-10-16 04:18:21
我假设insert()是BookList类的成员函数。如果这个假设是正确的,那么在使用.表示法时,必须对BookList实例而不是对类名本身调用它。因此,将其替换为:
BookList.insert(book, Position::BOTTOM);
有了这个
book_list.insert(book, Position::BOTTOM);
https://stackoverflow.com/questions/69592566
复制相似问题