When I instantiate an object in C ++ with the following class, I get a segmentation or interrupt error, depending on the order in which member variables are declared. E. g. putting mMemberVar and mAnotherMemberVar after mAnotherCountVar results in segfault. From this list, I removed std :: ofstream from member variables, which caused a segmentation error regardless of its position.
I think that order is not a direct problem, but what do you think might be the reason? This class is part of a huge project, but in this class this is the place where the error first appeared.
class COneClass : public IInterface
{
public:
COneClass();
virtual ~COneClass();
static const unsigned int sStaticVar;
static const unsigned int sAnotherStaticVar;
private:
COneClass();
COneClass(const COneClass& );
COneClass& operator=(const COneClass& );
int mMemberVar;
int mAnotherMemberVar;
bool mIsActive;
bool mBoolMemberVar;
bool mAnotherBoolMemberVar;
unsigned int mCountVar;
unsigned int mAnotherCountVar;
};
COneClass::COneClass() :
mMemberVar(0),
mAnotherMemberVar(0),
mIsActive(false),
mBoolMemberVar(false),
mAnotherBoolMemberVar(false),
mCountVar(sStaticVar),
mAnotherCountVar(sAnotherStaticVar)
{
}
Rainer
source
share