Tuesday, November 9, 2010

Explicit Constructors

In general, one argument constructors should be declared as explicit; otherwise unwanted implicit conversions could happen.

Implicit conversions can cause some strange behavior. See: http://blogs.msdn.com/oldnewthing/archive/2006/05/24/605974.aspx

Reference: Steve Weinrich, Unpublished Manuscript on C++ Design.

No comments:

Post a Comment