14
Tôi gặp một lớp học với operator[]
, như thế này:Làm thế nào để tạo một lớp mô hình với toán tử []?
class Base
{
public:
virtual ~Base(){}
virtual const int & operator[](const unsigned int index) const = 0;
};
Làm thế nào tôi có thể tạo ra một lớp giả sử dụng google khuôn khổ mô hình cho phương pháp này?
Tôi cố gắng này:
class MockBase : public Base
{
public:
MOCK_CONST_METHOD1(operator[],
const int& (const unsigned int)
);
};
nhưng điều đó tạo ra lỗi tiếp theo:
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
Cảm ơn. Điều đó làm việc tốt –
Làm thế nào mà sẽ làm việc cho các nhà điều hành chuyển nhượng? – Mawg