This is based on the original question that was asked here.
[Detailed]: Here is the relevant question as requested in comments
Lippman's c++ primer on p.303 mentions:
class Account {
private:
static constexpr int period = 30;
double daily_tbl[period];
}
If the member is used only in contexts where the compiler can substitute the member's value, then an initialized const or constexpr static need not be separately defined. However, if we use the member in a context in which the value cannot be substituted, then there must be a definition for that member.
Also:
For example, if we pass Account::period to a function that takes a const int&, then period must be defined.
So why does passing Account::period
to a function that takes a const int&
, needs that period
must be defined?
It will be very helpful to know,
- What is the rationale?
- Does the standard explicitly specify these scenarios or these are deduced from a more generic quotation?