If you can see the source class, you can make the mock class with the same bit pattern and pass the source object to an object of class mock
Example below
Original class
class ClassWithHiddenVariables { private: int a; double m; };
Mock class
class ExposeAnotherClass { public: int a_exposed; double m_exposed; };
If you want to see members of the ClassWithHiddenVariables object, use reinterpret_cast to transfer to ExposeAnotherClass
ClassWithHiddenVariables obj; obj.SetVariables(10, 20.02); ExposeAnotherClass *ptrExposedClass; ptrExposedClass = reinterpret_cast<ExposeAnotherClass*>(&obj); cout<<ptrExposedClass->a_exposed<<"\n"<<ptrExposedClass->m_exposed;
Jimmy source share