Search code examples
c++initialization-list

C++: Using two comma separated values for a single class member in initialization list


There is some C++ code. I would like to know why can two values be used for a single class member in initialization list (:OTMixerMgr(OTMediaType_Audio, oBridgeInfo))? Because usually only one value is used for a single class member, like
ClassName::ClassName(): fisrtMember(firstValue) {...}.

OTMixerMgrAudio::OTMixerMgrAudio(OTObjectWrapper<OTBridgeInfo*> oBridgeInfo)
:OTMixerMgr(OTMediaType_Audio, oBridgeInfo)
{
    m_phPullThread[0] = NULL;
    m_phPullCond = NULL;
    m_nLastTimerPull = 0;

    m_bStarted = false;
    m_bPaused = false;

    OT_ASSERT(m_phProducersMutex = tsk_mutex_create());
    OT_ASSERT(m_phConsumersMutex = tsk_mutex_create());

    m_oMixerAudio = OTMixerAudio::New(oBridgeInfo);

    m_bValid = (m_phConsumersMutex && m_oMixerAudio);
 }

This code is taken from Telepresence project, https://code.google.com/p/telepresence/source/browse/trunk/source/OTMixerMgrAudio.cc?r=118 , line 31

Thanks!


Solution

  • That isn't a class member, it is calling a base constructor with two arguments

    OTMixerMgrAudio::OTMixerMgrAudio(OTObjectWrapper<OTBridgeInfo*> oBridgeInfo)
     :OTMixerMgr(OTMediaType_Audio, oBridgeInfo) // call base constructor
    

    In fact, take a look at the header where OTMixerMgr is declared

    class OTMixerMgr : public OTObject
    {
    public:
            OTMixerMgr(OTMediaType_t eMediaType, OTObjectWrapper<OTBridgeInfo*> oBridgeInfo);