A::B X(void)
. 定义如下。
class A {
class B;
virtual B X() = 0;
};
class A::B {
public:
auto_ptr<int> something;
};
class mA : public A
{
public:
MOCK_METHOD0(X, A::B());
};
然而,这给了我一个奇怪的错误,我还没能找到它。这有什么问题?
In member function âvirtual A::B mA::X()â:
...: error: no matching function for call to âA::B::B(A::B)â
...: note: candidates are: A::B::B()
...: A::B::B(A::B&)
我找到了一个失败的代码示例来演示这一点。
#include <gmock/gmock.h>
#include <memory>
using std::auto_ptr;
class thing {
public:
class result;
virtual result accessor () = 0;
};
class thing::result {
auto_ptr<int> x; // If this just "int", error goes away.
};
namespace mock {
class thing : ::thing {
public:
MOCK_METHOD0 ( accessor, result() );
};
}