I have a class A having a number of Private/Public member functions/variables. I have added a new private member function to it. As part of a testing the newly added method, I need to invoke the private member function from my test class. In the case of member variables I have seen an example like below:
#include <iostream>
using namespace std;
class test
{
private:
int myInt;
public:
int getInt () {return myInt;}
};
int main ()
{
test t;
int* p = (int*) & t;
*p = 20;
cout << t.getInt ();
}
Output:20
Is there any reliable way I can access the private member function such that there is no code modification in the class A
?