Lecture 4 - Slide 23 : 40
Implicit Conversion
Conversion operators
TT::operator S()
and constructors
T::T(S)
can be called implicitly
Implicit conversions
A constructor can be used implicitly, unless it is marked
explicit
.
A conversion operator can be activated implicitly.
Too many implicit conversions may easily lead to ambiguities
The compiler finds out
The programmer will have to resolve such issues.
An alternative to conversion operators and implicit use
Program an ordinary member function instead of a conversion operator
int T::make_int(){...}
instead of
T::operator int(){...}