member-initialization

Complex statements in the member initialization part??

I have this: struct myClass{ multiset<string,binPred<string> > values ; myClass(const char param1, const char param2) : values(less<string>()) { } } ; I need to initialize the values member with a different functor depending on the values of param1 and param2. Unfortunately, the logic to decide which functor to use is not...

Right way to conditionally initialize a C++ member variable?

Hi, I'm sure this is a really simple question. The following code shows what I'm trying to do: class MemberClass { public: MemberClass(int abc){ } }; class MyClass { public: MemberClass m_class; MyClass(int xyz) { if(xyz == 42) m_class = MemberClass(12); else m_class = MemberClass(32...

How to refrain from CS2512 correctly

Please help me with the following problem: I have the following classes: class ChemicalElement { private: std::string _name; void Init(const std::string& name); public: ChemicalElement(const std::string& name); ChemicalElement(const ChemicalElement& ce); }; class CombinationRule { private: ChemicalElement _ce1; ...

Initialization of member: bug in GCC or my thinking?

I've got an enum type defined in the private section of my class. I have a member of this type defined as well. When I try to initialize this member in the constructor body, I get memory corruption problems at run-time. When I initialize it through an initialization list in the same constructor instead, I do not get memory corruption pro...