(type); avoid
static_cast<target-type>(val)
* and void *, int and
double, and so on
const or volatile modifiers
const_cast<target-type>(val)
reinterpret_cast<target-type>(val)
dynamic_cast<target-type>(val)
T::T(S sval)
bignum::bignum(const char *) { ... }
bignum & bignum::bignum = (const bignum & bn) { ... }
bn = "10.3";
"10.3" gets converted to a bignum, which gets assigned
bignum::bignum(const string &) { ... }
bignum & bignum::bignum == (const bignum & bn) { ... }
bn = "10.3";
"10.3" gets converted to a string, which gets converted to a bignum, which
gets assigned
explicit keyword can prevent these problems
operator target-type () - no return type, no arguments
bignum::bignum(const string &) { ... }
bignum::operator string () { ... }
bignum bn = static_cast(string("10.3"));
cout << static_cast<string>(bn) << "\n";
explicit
string bignum::get_string(void) const { return ...; }
cout << bn.get_string() << "\n";
This page last modified on 27 November 2001.