Update: I think I was able to narrow down the problem, see here for a new question that is hopefully more precise.
Update 2: I was able to solve the problem, see the link above :-)
I am trying to understand whether I got something fundamentally confused about how static member variables work.
I have a class (Lets call it cProvider) that contains static member variables (e.g. a pointer) and get/set methods. This class is included by two other classes, let's call them "cWriter" and "cReader", and both instantiate it. cWriter only accesses the setter methods, cReader accesses the getter methods.
My problem is that seem to be multiple instances of the static variables, meaning that when I access a static variable of cProvider through cWriter, it accesses a different physical location than when I access the same variable through cReader.
Is this something that is to be expected? I am doing this in a rather complex and probably unknown framework, ADTF. It might well be that the framework is responsible for this behavior. I checked the process IDs, and cWriter and cReader have the same process ID.
What could be the reason that they still access different addresses? I never had a formal programming education, so I might be missing something fundamental about how static variables work. I am happy for any hints about what could be the problem!
Edit: Condensed version of my code: (To show the gist)
OdometryHistoryWriter.h:
class cOdometryHistoryWriter
{
static bool something;
}
OdometryHistoryWriter.cpp:
bool cOdometryHistoryWriter::something;
OdometryHistoryProviderInputFilter.h:
#include OdometryHistoryWriter.h
class cOdometryHistoryProviderInputFilter
{
cOdometryHistoryWriter m_odoHistWriter;
void setSomething(boolvar);
}
OdometryHistoryProviderInputFilter.cpp:
#include OdometryHistoryProviderInputFilter.h
void OdometryHistoryProviderInputFilter::setSomething(boolvar)
{
m_odoHistWriter.something = boolvar;
return;
}
OdometryHistoryProvider.h:
class cOdometryHistoryProvider
{
bool getSomething();
cOdometryHistoryWriter m_odoHistAcessor;
}
OdometryHistoryProvider.cpp:
bool cOdometryHistoryProvider::getSomething()
{ return m_odoHistAcessor.something;}