Answers for "cpp when to use a member initializer list"

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

Code answers related to "cpp when to use a member initializer list"

Browse Popular Code Answers by Language