Why does Google Test/Mock show leaked mock object error by std::unique_ptr?

蓝咒 提交于 2019-12-05 18:16:44

The problem is that Foo does not have a virtual destructor. std::unique_ptr<Foo> thus won't be calling the derived class's destructor, just Foo's destructor.

class Foo
{
  public:
    virtual ~Foo() = default;
    virtual int F() = 0;
};

See When to use virtual destructors? If a base class Foo has virtual functions, it should either have a virtual destructor or a non-public destructor.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!