I read lippman C ++ primer where on p. 303 they give the following:
class Account { private: static constexpr int period = 30; double daily_tbl[period]; }
If a member is used only in those contexts where the compiler can substitute the value of an element, then the initialized const or constexpr static does not need to be defined separately. However, if we use an element in a context in which a value cannot be replaced, then there must be a definition for that element.
also:
For example, if we pass Account :: period to a function that takes const int &, then a period must be defined.
So I tried to add a function like this:
class Account { private: static constexpr int period = 30; double daily_tbl[period]; void foo(const int &i) { ; } void bar() { foo(period); }
There I added a function that takes const int &. I also did not add any period variable definition. But I'm still not mistaken, because they said that I should receive. Why not?
c ++
user2015453 Jan 27 '13 at 12:36 2013-01-27 12:36
source share