[Exceptional C++ Style] Item 17 - Encapsulation

Terje Slettebø terjesl at broadpark.no
Mon Dec 20 08:00:08 EST 2004


>From: "Adrian Fagg" <adrianf at evaluategroup.com>

> Three must be a reason why C and hence C++ calls parameterless functions
> with (), but it's always eluded me.

There exists, anyway, a proposal to change that, to make it easier to define
and use constants (avoiding the order-of-initialisation problem of global
variables):

http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2004/n1611.pdf

To quote:

double pi() implicit { return 3.1415926; } // ICF
double two_pi() implicit { return 2.0 * pi; } // ICF; note also the implicit
call

Regards,

Terje




More information about the Effective-cpp mailing list