Constructors in C++ — a practical guide to C++ constructors with clear examples you can reuse in real projects.
C++ Tutorial Series (52/111). Prefer one article? Read the complete C++ tutorial.
Short description
Prefer member initializer lists; mark single-arg constructors explicit when conversions are undesirable.
Constructor
struct Point {
Point(int x, int y) : x_(x), y_(y) {}
int x_, y_;
};