0
4

1 回答 1

2

您的match方法覆盖格式不正确。Catch::MatcherBase::match将对象作为对常量的引用,因此对象不会在方法体中被修改。签名为Catch::MatcherBase::match

virtual bool match(ObjectT const& arg) const

所以你的match覆盖实现应该是:

bool match(Book const& b) const override {
    return b.GetChapters() == chapters && b.GetPages() == pages;
}

此外,您需要标记您的Book吸气剂const以保持const 正确性

int GetChapters() const;
int GetPages() const;
于 2020-02-06T18:44:46.620 回答