I have a class contains a private property and a virtual method.
class A
{
private:
int var1;
virtual int foo()
{ return var1;}
public:
A(){ var1 = 2; }
};
In my "main" function I have:
A a;
cout<<func1(&a);
I want to get the value of var1 and return value of "foo" function in "func1" without changing the class. If I want to solve it I could add set and get methods for var1 but I am not suppose to change the class. How is it possible? Any reference for accessing private methods and properties from outside of the class?