August 2012
Intermediate to advanced
976 pages
30h 17m
English
static Data MembersOrdinarily, class static members may not be initialized in the class body. However, we can provide in-class initializers for static members that have const integral type and must do so for static members that are constexprs of literal type (§ 7.5.6, p. 299). The initializers must be constant expressions. Such members are themselves constant expressions; they can be used where a constant expression is required. For example, we can use an initialized static data member to specify the dimension of an array member:
class Account {public: static double rate() { return interestRate; } static void rate(double);private: static constexpr int period = 30;// period is a constant expression double ...
Read now
Unlock full access