I have a unit test class Tester; I want it to access private fields of a Working class.
Tester
Working
class Working { // ... private:
If you absolutely must do this, you could conditionally compile your code so that TestBase is a friend only when unit testing:
class Working { // ... private: int m_variable; #ifdef UNIT_TESTING friend class TestBase; #endif };