Constructors can have default arguments as functions do. For example,
#include <iostream>
class Point
{
int m_x{};
int m_y{};
public:
Point(int x, int y = 1)
: m_x{x}, m_y{y}
{
std::cout << "Constructor with one default arg y Point(x, y=1)\n";
}
void print() const
{
std::cout << "{" << m_x << ", " << m_y << "}\n";
}
};
int main(int argc, char const *argv[])
{
const Point point{2};
point.print();
return 0;
}point should have m_x as and m_y with default value .