Can someone explain me how the memory allocation and initialization in c++ works?
File Test.h
-----------
class Test
{
public:
Test();
void clearSet();
private:
std::set<std::string> m_SetStringMember;
int m_initMe;
}
File Test.cpp
-------------
Test::Test():m_initMe(0)
{}
Test::clearSet()
{
m_SetStringMember.clear();
}
What I do understand is:
The int member m_initMe is correctly initialized in the constructor and therefore has a valid adress in memory and a valid value.
But what happens with the m_SetStringMember?
Does it has to have a valid adress in memory?
Does it has to have a valid default value?
Set by the default constructor of std::set<std::string>()?
Or do I have to explicitly set m_SetStringMember = std::set<std::string>() in the constructor?
m_initMeit has memory(when you create the object) just that it has indeterminate value. same thing holds true form_SetStringMemberbut its invoked through default constructor which would give it a valid state..