I have a static function that is the entry point for a thread.
thisObject is a pointer to the class where the thread is instantiated.Code:static DWORD WINAPI readPacket(LPVOID thisObject)
Since the thread accesses data and functions found in the class, I had to make them static and define them outside of the class.
The problem is that other objects outside of the class now have access to the variables and can modify them.Code:}; static FILE *filterPacket_logfile; /* The logfile to log errors in*/ static std::string error; /*This is the error printed to the logfile*/ static int (*callback_Function)(unsigned char *, int); static void writeError(const char *errorString, int init_write);
Is there any way I can have variables that the thread can access but that other objects outside of the class cannot access.
I tried accessing the private data members of the class using thisObject but the compiler says it's an error. The compiler is MS visual Studio .NET 2003.
error C2248: 'filterPacket:ort_Name' : cannot access private member declared in class 'filterPacket'
Thanks a lot for any help,