In C++11, if you have a non-explicit constructor for a class A
that has multiple parameters (here I use A::A(std::string, int, std::string)
as an example), you can initialize an argument of that type with brace initialization:
void foo(A a);
foo({"the", 3, "parameters"});
Similarly, you can do the same with return values:
A bar() {
return {"the", 3, "parameters"};
}
If the constructor is, however, explicit
, these will not compile. Hence, the explicit
keyword now has importance for all constructors, rather than just conversion constructors.