Interesting indeed!
Guidelines for constructor and cast design
by Jonathan Müller
From the article:
A while back — but sadly not too many blog posts ago — I wrote about explicit constructors and how to handle assignment. In this blog post, I made the assumption that you most likely want to have explicit single argument constructors.
But when do we actually want implicit single argument constructors?
Let’s consider the broader question: How should I design a cast operation for my user-defined type? And how should I design a constructor?
But first, something different: what is the difference between a cast and a constructor?
Add a Comment
Comments are closed.