What’s the difference between initializing the object member variable m_A
in-class versus (class B
) in an initializer list (class C
)? Is one method more efficient or generally preferred over the other?
class A
{
public:
A(int num) { m_Int = num; }
private:
int m_Int;
};
class B
{
private:
A m_A{10};
};
class C
{
public:
C(): m_A(10) {};
private:
A m_A;
};