Mocking free function
问题 I am stuck in a problem and can't seem to find the solution. I am using VS2005 SP1 for compiling the code. I have a global function: A* foo(); I have a mock class class MockA : public A { public: MOCK_METHOD0 (bar, bool()); ... }; In the sources, it is accessed like this: foo()->bar() . I cannot find a way to mock this behavior. And I cannot change the sources, so the solution in google mock cook book is out of question. Any help or pointers in the right direction will be highly appreciated.