问问题
417 次
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 回答