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