Answers for "c++ initializer list a"

C++
3

member initializer list in c++

// Constructor Member Initializer List

#include <iostream>

class Example
{
private:
    int x, y;

public:
    Example() : x(0), y(0) {}
    Example(int x1, int y1) : x(x1), y(y1) {}
    ~Example() {}
};

int main()
{
    Example e;
}
Posted by: Guest on January-17-2021
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

Browse Popular Code Answers by Language