C# constructors overloading
public Point2D(Point2D point) : this(point.X, point.Y) { }
public Point2D(Point2D point) : this(point.X, point.Y) { }
With C++14, you may do: struct Date { public: Date(const Year& year, const Month& month, const Day& day) : d(day), m(month), y(year) {} template <typename T1, typename T2, typename T3> Date(const T1& t1, const T2& t2, const T3& t3) : Date(std::get<Year>(std::tie(t1, t2, t3)), std::get<Month>(std::tie(t1, t2, t3)), std::get<Day>(std::tie(t1, t2, t3))) {} private: Day d; Month m; … Read more
While there are no “official guidelines” I follow the principle of KISS and DRY. Make the overloaded constructors as simple as possible, and the simplest way is that they only call this(…). That way you only need to check and handle the parameters once and only once. public class Simple { public Simple() { this(null); … Read more