14
我有operator[]
一類,像這樣:如何用operator []創建一個模擬類?
class Base
{
public:
virtual ~Base(){}
virtual const int & operator[](const unsigned int index) const = 0;
};
我如何使用Google模擬框架此方法的模擬類?
我嘗試這樣做:
class MockBase : public Base
{
public:
MOCK_CONST_METHOD1(operator[],
const int& (const unsigned int)
);
};
但產生下一個錯誤:
error: pasting "]" and "_" does not give a valid preprocessing token
error: pasting "]" and "_" does not give a valid preprocessing token
error: pasting "]" and "_" does not give a valid preprocessing token
error: pasting "]" and "_" does not give a valid preprocessing token
謝謝。這工作正常 –
這將如何工作的賦值運算符? – Mawg