keyword explicit

From Cppwiki

Jump to: navigation, search

When used on a constructor that can be invoked with only one argument do not perform implicit conversion.

Example:

 struct foo {
   explicit foo(int n) : n(n) { }
   int n;
 };
 foo f(5);  // legal
 foo f = 5; // not legal
Personal tools