I recently found out about the explicit qualifier.
Let's pretend that:
f( W, W, W );
Now if we do
f( 42, 3.14, "seven" );
The compiler will attempt to perform the following implicit conversions:
f( W(42), W(3.14), W("seven") );
If we defined matching constructors for W, namely:
W(int); W(double); W(std::string);
... it will be successful.
However, if we make the first explicit:
explicit W(int);
... this disables implicit conversion.
Now you need to write:
f( W(42), 3.14, "seven" );
i.e. it makes you explicitly specify the conversion
Now to the question:
You can write:
explicit W(int,int);
It compiles!
But I do not see any relevant script that this syntax might require.
Can someone provide a minimal example?
source share