I'm attempting to implement class member container initiallization using array of member variables example code:
//Pseudo container declaration
class CContainer
{
template<size_t nSize>
CContainer(CMember* acArray[nSize]);
};
//class whos members i wanna pass as array to container initialization
class CProblematic
{
CMember m_1;
CMember m_2;
...
CMember m_n;
CContainer m_cContainer;
//constructor with container initialization
Virtual(int parameter)
: m_1(parameter)
, m_2(parameter)
...
, m_n(parameter)
, m_cContainer({&m_1, &m_2, ... , &m_n})
{}
};
I've tried multiple container constructor syntax, but none seem to help, for example i tried to use CContainer(CMember** apcArray, size_t nSize
and pass it during CProblematic
construction, but non seem to help when using {...}
style array creation, maybe someone could point me to my mistake or point toward solution?
I know that the easiest way to solve this is just simply add in constructor body m_cContainer.Add(&m_1)
for each member, but i'm more interested is there a solution to initiallize this way...
Aucun commentaire:
Enregistrer un commentaire