I am developing code that solves about 100 equations. Most of theses equations are computed in private members, because in the end the user doesn't care about them. But, right now I do. So, as I develop the code I would like to have a quick way to test private members.
The code below gives the basic behavior that I want, but it does not work (privacy issue). If this behavior is possible, I would appreciate any help.
// Includes
#include <stdio.h>
// I want a general test class that can access private members
template <class Name> class TestClass{
public:
TestClass(Name& input) : the_class(input){}
Name& operator()(){ return the_class; }
Name& the_class;
};
// The class I want to test
class ClassA{
public:
friend class TestClass<ClassA>; // I hoped this would do it, but it doesn't
ClassA(){}
private:
void priv(){ printf("a private function\n"); }
};
// Main function that preforms the testing
int main (){
ClassA a;
TestClass<ClassA> b(a);
b().priv(); // I want to do this
}