In C++, a constructor labelled explicit is only ever called when named in the program. It may therefore not be used to match a call to a function with a different signature -- the constructor is only used when explicitly requested.

An example is in order. Suppose I have a class Histogram, which represents k-tuple frequencies in a block of text. It makes sense to have k as an argument to the constructor:

class Histogram {
private:
  // ...
public:
  Histogram(int k);
  // ...
};
It also makes sense to calculate entropy for the distribution that a Histogram represents, so I declare (and define) a function double entropy(Histogram);.

What happens if I call entropy(17) from my code? Well, it makes no sense (I defined entropy for distributions, not numbers), so you'd expect the type system to flag an error. Well, it doesn't. What happens instead is that the compiler constructs a temporary Histogram (for 17-tuples, naturally), and passes that to entropy.

To prevent this sort of gratuitous conversion from occurring, flag the constructor explicit.