Answers for "c++ list initialization constructor"

C++
0

initializer list c++

class Example {
public:
	int m_A, m_B, m_C;
	Example(int a, int b, int c);
};

Example::Example(int a, int b, int c):
	// This is an initializer list
	m_A(a),
	m_B(b),
	m_C(c)
{ /* Constructor code */ }
Posted by: Guest on January-31-2021
-2

c++ initialization list

class Something
{
private:
    int m_value1;
    double m_value2;
    char m_value3;
 
public:
    Something()
    {
        // These are all assignments, not initializations
        m_value1 = 1;
        m_value2 = 2.2;
        m_value3 = 'c';
    }
};
Posted by: Guest on April-19-2020

Browse Popular Code Answers by Language