This question refers to the previous C ++ 11 standard (C ++ 03). explicit prevents implicit conversions from one type to another. For example:
struct Foo { explicit Foo(int); }; Foo f = 5;
If we have a constructor that takes two or more parameters, what will prevent explicit ? I understand that in C ++ 11 you have a fixed initialization, so it will prevent constructs such as:
struct Foo { explicit Foo(int, int); }; Foo f = {4, 2};
But in C ++ 03, we donβt have fixed initialization, so what construct is explicit keyword prevention here?
c ++ c ++ 03
template boy
source share