I've seen the above in some c++ code and wonder what is happening. Can anyone explain what this means to me?
SomeManager::SomeManager()
: m_someinterface(NULL)
, m_someinterface(NULL)
{
}
I've seen the above in some c++ code and wonder what is happening. Can anyone explain what this means to me?
SomeManager::SomeManager()
: m_someinterface(NULL)
, m_someinterface(NULL)
{
}
I think you mean the following
SomeManager::SomeManager() : m_someinterface(NULL) , m_someinterface(NULL)
{
}
It is a definition of a constructor of class SomeManager
that have mem-initializer list
m_someinterface(NULL) , m_someinterface(NULL)
where its subobjects (data members and/or base class subobjects) are initialized.
Take into account that data members shall have different names like for example m_someinterface1 m_someinterface2.
Here is a simple example
class A
{
public:
A();
private:
int x;
int y;
};
A::A() : x( 10 ), y( 20 ) {}
After creating an object of the class like
A a;
its data members a.x
and a.y
will have correspondingly values 10 and 20.
Or another example where the base class constructor is called explicitly
class A
{
public:
A( int x, int y ) : x( x ), y( y ) {}
private:
int x;
int y;
};
class B : piblic A
{
public:
B( int );
private:
int z;
};
B::B( int z ) : A( z / 10, z % 10 ), z( z ) {}